I have a script a.sh, which has an sftp command:echo Starting to sftp...sftp xxx@xxx.xxx.xxx.xx << END_SCRIPTlsmput *.csv.gzbyeEND_SCRIPTecho Sftp successfully.If I run it interactively, the log output from sftp is shown. However, if I set it in a crontab and redirect the stdout to a file using >, there will be only the output from the two echo statements. How can I get the log from the sftp command?EDIT:I tried the following forms and it didn't work too.sftp -b batch_file.txt xxx@xxx.xxx.xx.xx ( redirect from cron )sftp -b batch_file.txt xxx@xxx.xxx.xx.xx >> some_file.log ( redirect from cron + redirect from this line )I think the problem should be related to the nature of sftp that it is supposed to be run interactively, as stated in the man page. But I cannot find the solution.My distribution : Red Hat Enterprise Linux AS release 3 (Taroon Update 2)the crontab entry:52 14 * * * sh /home/xxx/testing/xxx.sh > /home/xxx/testing/xxx_`date +\%Y\%m\%d`.logAnd the log is created with a time matching the crontab entry.ssh version:OpenSSH_3.6.1p2, SSH protocols 1.5/2.0, OpenSSL 0x0090701fEDIT:I found that if I redirect the output of sftp in the script file to an text file, the message from sftp is logged. Then I remove the log file and scheduled it with cron. After the cron execution, the log file is generated but have no message from sftp. Instead, it only contain log from other statement inside the script file.If I redirect the output of sftp in script file and run it interactively, the log are perfectly fine. However if I scheduled it with cron ( no redirect in the crontab entry, just simply schedule it ), the log from sftp is gone too.
Why does sftp hide the log from stdout?
cron;io redirection;sftp