Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

Expect: how to properly close a while loop in bash using infinite expect spawn?

$
0
0

I have the following script:

#!/usr/bin/expectset timeout 20set cmd [lrange $argv 1 end]set password [lindex $argv 0]eval spawn $cmdwhile {1} {  expect "id_rsa"  send "$password\r";}interact

which intends to expect "id_rsa" and enter the password repeatedly while the spawned $cmd is open.

Now the script works but will always end with error

send: spawn id expx not open while executing ...

I want to write my code in a proper way such that the while loop is exited properly via check and not via error catching in expect so that the error will not show up.

Thanks in advance.


Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>