Posted to tcl by Texan at Tue May 23 14:49:10 GMT 2017view pretty
#!/usr/bin/expect set passwdPrompt "password" set loginUser "user" set loginPassword "pass" set address "addr" spawn ssh -l $loginUser $address expect "$passwdPrompt" { send "$loginPassword\r" } proc login_from_protected_shell { } { set timeout 2 expect { timeout { puts "Function 1 timed out" return 1 } "<protected shell>" { send -- "shell\r" exp_continue } "password" { send "<somepass>\r" exp_continue } "<shell>" { # nothing to do, success! return 0 } } } proc other_things_to_do { } { expect "<shell>" { send "cd /home/mydir\r" } expect "<shell>" { send "touch poop.pee\r" return 0 } } # drop to a shell login_simple # download the base other_things_to_do