if condition for sftp bash using expect on ubuntu / linux

I created .sh file to mget and rm file from different server which use sftp.

expect "sftp>"
send "cd SOURCE.DIRn"
expect "sftp>"
send "lcd DEST.DIRn"
expect "sftp>"
send "mget *.TXTn"
expect "sftp>"
send "rm *.TXTn"

My problem is I only need [send "mget *.TXTn"] executed when there are files exist in SOURCE.DIR, and ["mget *.TXTn"] executed when there are files exist in DEST.DIR.


Source: ubuntu

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.