Ftp autoconnect and send commands

From wiki.network-crawler.de
Jump to: navigation, search
#!/usr/bin/expect -f
set FTPSYSTEM [lindex $argv 0]
set FTPUSER [lindex $argv 1]
set FTPPASSWORD [lindex $argv 2]
set FTPCOMMAND "ls\r"

spawn /usr/bin/ftp $FTPSYSTEM
expect "Name ($FTPSYSTEM:$env(USER)):"
send "$FTPUSER\r"
expect "Password:"
send "$FTPPASSWORD\r"
expect "ftp> "
send $FTPCOMMAND
expect "ftp> "
send "bye \r"
exit 0