shell - how do I use expect along with a bash script -


i have text file bunch of operations send using expect script looks (replacing op1 & op2 commands in textr file, 1 command per line):

#!/usr/bin/expect spawn ssh root@cctest telnet jpaxdp expect {\-> } send "op1(20)\r" expect {\-> } send "op2\r" expect {\-> } send "exit\r" expect eof 

how can this?

i don't think understand question. seems me easiest thing let expect handle reading file:

#!/usr/bin/expect set command_file [lindex $argv 0] spawn ssh root@cctest telnet jpaxdp expect {\-> }  set fh [open $command_file r] while {[gets $fh line] != -1} {     send "$line\r"     expect {\-> } } close $fh  send "exit\r" expect eof 

then


Comments