I am accessing a SFTP via LFTP using the script below. It runs from cron at 4/11/16/23. For some unknown reason at unknown intervals I am getting failures. How can print a log file that will confirm ls -l for the file I am uploading? I am hoping it can be wrapped into the existing script. Is there a better way to log a confirm than ls -l?
# Upload to SFTP via LFTP
#
host="hostname.com"
user="usrname"
pass="passw"
rdir="remote/dir"
file="upload-file.txt"
lftp -u $user,$pass sftp://$host -e "cd $rdir ; put $file ; bye"
#
You can enable debug using, well, the "debug" command. With -o FILE option it can save the debug output to the file. Also you can add "ls -l >> file" after put command to append the ls output to the file.
For example:
lftp -e "debug -o debug.log; put file; ls file >> remote-ls.log; bye" sftp://user:pass@host.example.com/remote/path
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.