I have deployed an expect script on a remote server, which I want to run via ssh.
ssh user@host 'expect -d ./netopeer_expect.sh' (1)
user@host:~$ cat netopeer_expect.sh
#!/usr/bin/expect
set timeout 5
#spawn netopeer2-cli
spawn ./np2_multi_cli
expect ">"
send "listen --timeout 120\r"
expect "ru_id 0"
send "get-config -D=0 --source running --out /home/user/out.xml\r"
expect ">"
send "exit\r"
expect "$"
This code runs a modified version of the netopeer2-cli, which we call ./np2_multi_cli. This netopeer2-cli have an own shell and a prompt like >. It works fine when I do it in two steps
ssh user@host
expect -d ./netopeer_expect.sh (2)
However, the message
send "get-config -D=0 --source running --out /home/user/out.xml\r"
is cut and is sent as,
send "-D=0 --source running --out /home/user/out.xml\r"
From running (1) with the -d argument I see this,
expect: does "\u001b[6n" (spawn_id exp3) match glob pattern ">"? no
When I try to match the first >. When I instead try to run (2), it looks as it should,
expect: does "> " (spawn_id exp4) match glob pattern ">"? yes
I run bash and it seems as if there are some encoding issues regarding the > character. Any idea how to deal with this?
BR Patrik
