1.30.2014

Linux Expect Script to SFTP files

Linux Expect Script to SFTP files

Install Expect

sudo apt-get install expect

sudo apt-get install expect

Linux Shell Script

pico remote_backup.sh

#!/usr/bin/expect -f
cd /etc/postfix
spawn sftp username@sftpserver
expect "password:"
send "<password> \n"
expect "sftp>"
send "mput relay_recipients \r"
expect "sftp>"
send "mput transport \r"
expect "sftp>"
send "mput /etc/postgrey/whitelist_clients \r"
expect "sftp>"
send "quite \r"

Make the Script an executable file
chmod +x remote_backup.sh

Run the shell script
./remote_backup.sh

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.