localdir=some/other/path
remotedir=some/path files=...... sftp_opts="-b - " errors="" success="" for file in $files do local=$localdir/$file test -f "$local" || { wlog "Not a file: $local" next } remote=$remotedir/`basename $file` remotetmp=$remote.tmp # # Remove old remote file # echo "rm $remotetmp" | sftp $sftp_opt $sftpuser@$sftpserver >> $LOG 2>&1 echo "rm $remote" | sftp $sftp_opt $sftpuser@$sftpserver >> $LOG 2>&1 wlog "Start $local -> $remote" result=`( echo "put $local $remotetmp" echo "mv $remotetmp $remote" ) | sftp $sftp_opt $sftpuser@$sftpserver 2>&1` || { wlog "SFTP failed" errors="$errors $local" next } wlog "$result" echo "$result" | egrep -i '(error|fail)' >/dev/null && { wlog "some error ...." errors="$errors $local" next 1 } success="$success $local" wlog "Finished $local -> $remote" done test -z "$errors" || { wlog "perkele virheita: $errors" } test -z "$success" && { wlog "OOps mikaan ei onnistunut" }
syntax highlighted by Code2HTML, v. 0.9.1
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!