The three commands send, expect, and spawn are the building power of Expect. The send command sends strings to a process, the expect command waits for strings from a process, and the spawn command starts a process.
This script will automatically connect to the ftp server and will just do an ls on the server
#!/usr/sbin/expect
spawn ftp domain.com
expect "Name (domain.com:root):"
send "test@domain.com\r"
expect "Password:"
send "qwert\r" //qwert is password \r is part of syntax//
expect "ftp>"
send "ls\r"
expect "ftp>"
send "bye"
interact
save this as a file and give permission 755
after that run this as
# expect scriptname
Cheers
Nobs
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment