I have problem with my simple code, the expect can not expect the output
set timeout 10
set user username
set password password
spawn ssh $user@000.000.000.000
expect "Password:"
send "$password\r"
expect eof
send "cv mk ghassan-test-5\r"
sleep 45
expect "ok" { send "cv set ghassan-test-5\r" }
sleep 20
expect -gl "Ok" { send "cv rbset ghassan-test-5\r" }
expect eof
sleep 20
expect -gl "Ok" { send "cv ls\r" }
sleep 10
expect eof`
send "exit\r"
the script run and and enter to the remote server
but after send "cv mk ghassan-test-5\r"
the output is generated, .....
Please wait while database is writing to disk.
Writing the database file can take minutes...
ok, but when the script run the next line expect "ok" { send "cv set ghassan-test-5\r" }
it did not run and did not expect the ok
since the ok
but if i expect minutes insted of ok it work fine (the ok
appear after 1 minute)
\r
instead of\n
? – terdon May 06 '13 at 12:29send \r
means "the user pressed the Enter key" – glenn jackman May 06 '13 at 12:54exp_internal 1
to the top of the script, and expect will show you why it's not matching. – glenn jackman May 06 '13 at 12:55