LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to send '}' in expect? (https://www.linuxquestions.org/questions/programming-9/how-to-send-%7D-in-expect-881905/)

f4dleep 05-21-2011 01:19 AM

How to send '}' in expect?
 
Hi,

I'm trying to use expect to get data from telnet

Here's my code :
Code:

set equipment [lindex $argv 0]
set trunk [lindex $argv 1]
set fraction [lindex $argv 2]

set user1 "rnanaha8"
set pass1 "anggur#1"
set user2 "rzulkif8"
set pass2 "Abyan_2011"

spawn ssh rnanaha8@10.2.81.116
expect "*word*" { send "$pass1\r" }
expect "*$user1*" { send "telnet 10.105.224.68\r" }
expect "*ogin*" { send "$user2\r" }
expect "*asswor*" { send "$pass2\r" }
expect "*ANCB*" { send "gsh get_e1t1_frac -eq {$equipment} -trunk $trunk -frac $fraction\r" }
expect "*ANCB*" { send "exit\r" }
expect "*$user1*" { send "exit\r" }
expect eof

but this get error

Build label: NDPGSN_5_0_SRC_GSN_LINUX_4R1D01
Build host: selnx056
Build date: Thu Feb 19 20:50:48 MET 2009
Installed: Sat Dec 19 11:32:38 UTC 2009

=== rzulkif8@eqm01s13p2 ANCB ~ # gsh get_e1t1_frac -eq {2 6 1 1
Missing }.
=== rzulkif8@eqm01s13p2 ANCB ~ # } -trunk 3
}: Command not found.
=== rzulkif8@eqm01s13p2 ANCB ~ # -frac 16
-frac: Command not found.

=== rzulkif8@eqm01s13p2 ANCB ~ #
=== rzulkif8@eqm01s13p2 ANCB ~ # exit
logout
================================================

so in bold letter not send in 1 line, but i want sent it to 1 line

thank's for your suggestion

Snark1994 05-21-2011 06:30 AM

I don't know, but it looks to me like the '}' after '$equipment' is confusing it... Perhaps you could try escaping it?

f4dleep 05-24-2011 07:26 PM

dear Snark1994.

thank you for your suggestion
I've try escaping it, but still command not send in 1 line :(

any idea ?


All times are GMT -5. The time now is 01:06 AM.