2
#!/opt/sfw/bin/expect --
spawn telnet -e ! [lindex $argv 0]
expect "<"
send "ACT-USER::ABCDEFG:123::\"ABCD\";"

Above is not working giving error due to double quote inside a double quote

Error:

    spawn telnet -e !
Telnet escape character is '!'.
invalid flags
send: spawn id exp7 not open
    while executing
"send "ACT-USER::ABCDEFG:123::'\"ABCD\"';""
    (file "./get-amp-pms.sh" line 4)
evil otto
  • 10,348
  • 25
  • 38
Amar
  • 31
  • 2

3 Answers3

2

Use curly braces instead of the double quotes for the send, as follows:

send {ACT-USER::ABCDEFG:123::"ABCD";}
Akshay Damle
  • 1,220
  • 3
  • 18
  • 31
1

The error is unrelated to the double-quoting; the spawned process is exiting on an error before the command string is being sent.

expect is tcl, so tcl quoting mechanisms work. Sending a string with double quotes can be done by escaping the quoted with backslashes, or using braces:

send "message with \"double quotes\""
send {message with "double quotes"}
evil otto
  • 10,348
  • 25
  • 38
0

Not sure But we can use single quote in few commands like(sed) to overcome this issue and freely use double quote inside single quote without hampering the functionality.So try using the parameters enclosed in single quote(Example : send 'paramters' )to execute it