Expect: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Links. | ==Links.== | ||
http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html | http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html | ||
http://expect.nist.gov/scripts/ | http://expect.nist.gov/scripts/ | ||
==info== | |||
timeout | |||
set timeout 60 | |||
timeout of -1 signifies that expect should wait forever. | |||
timeout 0 indicates that expect should not wait at all. | |||
==scripts== | |||
<pre> | <pre> |
Revision as of 07:35, 15 May 2008
Links.
http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html http://expect.nist.gov/scripts/
info
timeout
set timeout 60
timeout of -1 signifies that expect should wait forever. timeout 0 indicates that expect should not wait at all.
scripts
Script. #!/usr/bin/expect -f # # expect_ssh.exp # bjorklun # if { $argc < 1 } { send_user "Usage: ./ssh-login.exp <username> <password> <hostname> <command> \r" exit } # set username [lrange $argv 0 0] set password [lrange $argv 1 1] set hostname [lrange $argv 2 2] set command [lrange $argv 3 3] set arguments [lrange $argv 4 9] set timeout -1 match_max 1000 spawn ssh $username@$hostname $command $arguments expect { "Are you sure you want to continue connecting (yes/no)? " { send -- "yes\r" expect "*?assword:*" { send -- "$password\r" send -- "\r" } } "*?assword:*" { send -- "$password\r" send -- "\r" } "*denied*" { puts "You are a loser Andreas\r" } } expect eof