I need a script to configure PDU (power distribution unit). The script will be called from another program. I created Expect script that gets parameters, connects to PDU by ssh and runs the command. The short commands, such as 'pwd' or 'lang' works correctly, but the long commands stuck waiting for user interaction. If I do nothing, the connection is closed after timeout, if I press Enter, the script continue and pass.
There is a script:
spawn ssh $user@$pdu
interact -o -nobuffer "assword:" return
send "$password\r"
interact -o -nobuffer "apc>" return
send "olStatus $host\r"
interact -o -nobuffer "apc>" return
Running it with debug flag gave the following output
apc>tty_set: raw = 0, echo = 1
send: sending "olStatus machine-123456\r" to { exp4 }
defining key apc>, action return
tty_raw_noecho: was raw = 0 echo = 1
spawn id exp4 sent <olStatus machine-123>
olStatus machine-123spawn id exp0 sent <\r>
spawn id exp4 sent <456\r\n23: machine-123456: On \r\nE000: Success\r\n\r\napc>\r\napc>>
456
23: machine-123456: On
E000: Success
How can I solve the problem?