unix

Upload clocking script

谁说我不能喝 提交于 2020-01-15 11:45:06
问题 How can I make a script that, once a day, will upload a file via ftp to several different servers, then take note (in a log) of how much time the uploads took? Thanks to Rajax I have the cronjob set up to execute this so far as the script, let's say it's called ftpScript.sh: #!/bin/sh HOST='ftp.users.qwest.net' USER='MYUSERNAME' PASSWD='MYPASSWORD' FILE='filename.gif' ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD put $FILE quit END_SCRIPT exit 0 Where do I put this part? time

Multiple unix pipes not working

我的未来我决定 提交于 2020-01-15 11:15:52
问题 This first pipeline works fine (printing "c"): echo "a" | sed 's/a/b/' | sed 's/b/c/' This one does not do what I expect (nothing gets printed when I feed an "a" into my fifo ): mkfifo fifo; cat fifo | sed 's/a/b/' | sed 's/b/c/' However, if I remove the second "sed" command from the latter pipeline, I do get a "b" printed. I think my understanding of pipes and redirects must be too simplistic. Can someone explain to me how to fix the 2nd case so that I can run two successive commands on the

OsX, can't use Homebrew because of Ruby permission

北城余情 提交于 2020-01-15 09:32:22
问题 I have seen many related questions and posts, but I just can't fix my problems. I am running El Capitan and I want to have Homebrew and Ruby running. But if I want to run Homebrew I get permission errors like: bio89093:~ jonbra$ brew doctor /Library/Ruby/Site/2.0.0/rubygems.rb:1219:in `register_default_spec': undefined method `default_gems_use_full_paths?' for Gem:Module (NoMethodError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/specification.rb

Understanding which swprintf will be used (or again, convert a char* string to wchar_t*)

泄露秘密 提交于 2020-01-15 09:14:34
问题 I am trying to convert a char* string to wchar_t*. I have seen this question has been asked many times, with no resolving/portable answer/solution. As suggested here, swprintf seemed the right solution to me, but I found out there exist two versions out there!! Namely: http://www.cplusplus.com/reference/cwchar/swprintf/ (second argument is the string capacity) http://msdn.microsoft.com/en-us/library/ybk95axf%28v=vs.71%29.aspx (second argument is already the format string) My program would

Bad substitution error in ksh [duplicate]

依然范特西╮ 提交于 2020-01-15 09:13:48
问题 This question already has answers here : Cannot debug simple ksh programme (2 answers) Closed 5 years ago . The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88 , not ksh93 . #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$len/2 print $halflen while ((i < $halflen)) do if [[ ${strtochk:i:1} == ${strtochk:j:1} ]];then (i++) (j--) else ispalindrome="false" break fi done print ispalindrome But I am

Bad substitution error in ksh [duplicate]

廉价感情. 提交于 2020-01-15 09:13:22
问题 This question already has answers here : Cannot debug simple ksh programme (2 answers) Closed 5 years ago . The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88 , not ksh93 . #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$len/2 print $halflen while ((i < $halflen)) do if [[ ${strtochk:i:1} == ${strtochk:j:1} ]];then (i++) (j--) else ispalindrome="false" break fi done print ispalindrome But I am

Bad substitution error in ksh [duplicate]

为君一笑 提交于 2020-01-15 09:12:32
问题 This question already has answers here : Cannot debug simple ksh programme (2 answers) Closed 5 years ago . The following KornShell (ksh) script should check if the string is a palindrome. I am using ksh88 , not ksh93 . #!/bin/ksh strtochk="naman" ispalindrome="true" len=${#strtochk} i=0 j=$((${#strtochk} - 1)) halflen=$len/2 print $halflen while ((i < $halflen)) do if [[ ${strtochk:i:1} == ${strtochk:j:1} ]];then (i++) (j--) else ispalindrome="false" break fi done print ispalindrome But I am

nginx与php-fpm通信的两种方式

社会主义新天地 提交于 2020-01-15 08:58:56
转载:http://blog.csdn.net/koastal/article/details/52303316 简述 在linux中,nginx服务器和php-fpm可以通过tcp socket和unix socket两种方式实现。 unix socket是一种终端,可以使同一台操作系统上的两个或多个进程进行数据通信。这种方式需要再nginx配置文件中填写php-fpm的pid文件位置,效率要比tcp socket高。 tcp socket的优点是可以跨服务器,当nginx和php-fpm不在同一台机器上时,只能使用这种方式。 windows系统只能使用tcp socket的通信方式 配置方法 tcp socket tcp socket通信方式,需要在nginx配置文件中填写php-fpm运行的ip地址和端口号。 location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } unix socket unix socket通信方式,需要在nginx配置文件中填写php-fpm运行的pid文件地址。 location

Linux reading from file strange behaviour

坚强是说给别人听的谎言 提交于 2020-01-15 08:41:11
问题 I'm trying to make a program that creates a file, writes 0 into it and then, using a child process, alternates the incrementation of that that value. For example, the child should increment that value to 1, and writes it back to the file. After this, the parent increments it to 2 and writes it in the file. The child to 3, and so on. Synchronization between the processes is done via signals. Here is the source code: #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <signal.h>

Bash - how to list files with size in bytes

拈花ヽ惹草 提交于 2020-01-15 08:13:44
问题 I am wanting to use the ls command to output the files in a directory however I need the file size in bytes. Is this possible with the ls command? on similar questions i've found this ls -l --block-size=M which outputs the file size in megabytes however I cannot seem to get it to work with just bytes. 回答1: If you are looking for statistics about files, then you want to use stat rather than ls . eg: stat --format=%n:%s * 回答2: $ ls -l foo.tar.gz -rw-r--r-- 1 tex tex 68964464 Mar 12 2014 xfer