I'm trying to automate some operations with the VC systems I administer, and the manufacturer has MANY inconsistencies in their interface.

I'm trying to match a system H323 name and device name, but...

If I do systemname get, the answer is name\r\n If I do h323name get, the answer from the device is name \r\n. -> the space between name and CR is killing me.

In both cases, I'm using expect "*\r\n" and then using $expect_out(0,buffer) as my variable.

Of course, later on when I try to match the names, I always get a negative, even though the names are the same.

How can I manipulate the variables or change what I'm expecting to get: 1. rid of the space bar for h323name or 2. add a space bar after systemname so my query will work?

  • 1
    AFAIK expect is Tcl, and looking at this page I think [string trim $expect_out(0,buffer)] might do what you want. It gives the trimmed string as return value. – celtschk Sep 6 '14 at 9:14
  • Great suggestion! Worked with variations: (argh having problems to format it) set systemtrim [string trimright $systemname "\r\n"] set h323trim [string trimright $h323name " \r\n"] if {[string equal -nocase $systemtrim $h323trim] == 1} { send_user "True" } if {[string equal -nocase $systemtrim $h323trim] == 0} { send_user "False" }' – Shiunbird Sep 6 '14 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.