Bash and sftp
Hello, I need to copy every hour some files from local directory to remote vis sftp.
I open 1 session for all files and copy them to remote host with mput. But if the copying would be wrong - for example connection would be lost. How I can know abouit it in the Bash. PHP Code:
|
First, in timed things like this, you might consider building this as a cron job. It can make the script less complex and gets rid of the need of another programming running all of the time.
Now then, to answer your actual question. After: sftp -b /dev/fd/0 $TARGET_USER@$TARGET_HOST>>$FTPLOG 2>&1<<EOT try checking the exit status of sftp. Like: Code:
RET=$? |
Quote:
sftp session working on remote computer and there script could'nt copy some files or some permissions incorrect. And that its why sftp will give Code:
RET=$? |
If you want to know the status of the copy and chmod on a file-by-file basis, you'll need to replace the while loop with
for file in *.zip sftp .... lcd .. put $file ie perform the copy, then exit and check the status, then do another sftp cxn and run the chmod cmd and check it. |
Quote:
|
Then you can't do it... in SFTP
Look, you can either send & chmod all the files in one go, then use an ssh session to do a remote 'ls -l' (assuming you can ssh in), or you check each operation as you go. Your choice. Another way that might do what you want with one session would be to use one of the Perl SSH modules. I think you'd be able to do an scp within the ssh session, as well as the chmod cmd, and check as you go. |
All times are GMT -5. The time now is 07:50 AM. |