Home > database >  Check lftp status when executing SFTP from shell script
Check lftp status when executing SFTP from shell script

Time:11-25

I am using lftp to connect to SFTP server using the below in a shell script.

host=testurl.url.com
user=username
pass=pass

lftp<<EOF
open sftp://${host}
user ${user} ${pass}
cd test/myfolder/
bye
EOF

when executing the above using a shell script, the script exits but I am not sure if a connection is established and I don't see the output of my cd command which I executed within lftp.

Is there a way to output to a log file to see if connection is successful and the output of cd command.

Thank you.

CodePudding user response:

I added a ls to the list of commands and I was able to list the directories

host=testurl.url.com
user=username
pass=pass

lftp<<EOF
open sftp://${host}
user ${user} ${pass}
cd test/myfolder/
ls
bye
EOF
  • Related