linux - second "send" command in expect script is not waiting to finish the Output of first command -


i have small expect script . flow follows

  1. ssh remote machine
  2. execute command , after executing command in different prompt ( prompt name enter cmd>.
  3. on enter cmd> prompt, need run many commands

hence designed script

#!/usr/bin/expect   set full_cmd { #cmd1 #cmd2 #cmd3  }  puts "starting......."   log_file myfile.log ;# <<< === append output file  spawn ssh tempuser\@dummyserver  match_max  100000000   expect "password:"  send "temppasswd\r" expect  "*temp*"  send "cd \/home\r"  expect "*temp*" send "new cmd prompt\r" expect "enter cmd>"  foreach tempcmd $full_cmd {  send "${tempcmd} \r "  expect -exact  "enter cmd>\r"  send -- "\r" expect eof }  send "q" send "exit\r"  puts "i have ended......." 

my problem: o/p of first command cmd#1 long , can see expect script not waiting o/p of first command complete , sending second command cmd#2 after time.

this script works fine on systems o/p of cmd#1 small, on systems the o/p of cmd#1 large (say 1000000 lines), has trouble, i.e. issues first command cmd#1 , o/p follows, before enter cmd> prompt, script issues second command cmd#2

how can ensure command cmd#2 sent after output of cmd#1 completes?

try setting timeout @ start:

set timeout 60 

or use -1 wait forever.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -