Expect Example

Here is a very simple script illustrating the use of expect:

#!/usr/bin/expect -f
log_user 0
set server [lrange $argv 0 0]
set from [lrange $argv 1 1]
set to [lrange $argv 2 2]
set message [lrange $argv 3 end]
spawn telnet "$server" 25
send "EHLO me\r"
set timeout 30
send "MAIL FROM: $from\r"
send "RCPT TO: $to\r"
send "DATA\r"
send "$message\r"
send ".\r"
send "QUIT\r"
expect oef

About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]