0

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"
# 
Dan K
  • 25
  • 6
  • what does a negative score mean? can anyone help? – Dan K Jun 02 '16 at 13:12
  • can anyone help? Google doesnt seem to have an example close enough that I can understand and the man pages are still a little bit beyond my understanding....... – Dan K Jun 03 '16 at 03:13

1 Answers1

0

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
lav
  • 1,351
  • 9
  • 17
  • 1
    He wants to get the state of the file on the remote system, not the local system. "ls" won't list files on remote systems. – Kenster Jun 03 '16 at 20:51
  • 1
    Inside the quotes after -e option there are lftp commands and an ls there would print the state of the remote file. – lav Jun 04 '16 at 04:08
  • Lav - can you give me an example on how I would go about using the -o option to save ls on the remote to a folder on my local? – Dan K Jun 06 '16 at 00:54
  • I have added an example to my answer. – lav Jun 06 '16 at 02:47