LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   expect question (http://www.linuxquestions.org/questions/programming-9/expect-question-350386/)

deiussum 08-05-2005 04:51 PM

expect question
 
I started working on my very first expect script and had a quick question. Basically, my script is just something I am using to use the TCPquery port of my TeamSpeak server to see if anyone is logged in. I've got the basic script working pretty well, but I wanted to change the output of it somewhat.

Reading the man page, it sounds like the expect command stty -echo is supposed to turn off echoing, but it doesn't seem to turn off echoing of any sort. For instance, if I have an expect script like so:

Code:

#!/usr/bin/expect -f
stty -echo
spawn telnet localhost 51234
expect "TS"
send "sel 8767\n"
expect {
    "OK" { send "login user password\n" }
    "ERROR" exit
}
expect {
    "OK"  {
          stty echo
          send "pl\n" }
    "ERROR" exit
}
expect {
    "OK" {send "quit"}
    "ERROR" {send "quit"}
}

I get the following:

Code:

$ ./lsts2
spawn telnet localhost 51234
Trying 127.0.0.1...
Connected to localhost.

Escape character is '^]'.
[TS]
sel 8767
OK
login user password
OK
pl
p_id    c_id    ps      bs      pr      br      pl      ping    logintimeidletim
e      cprivs  pprivs  pflags  ip      nick    loginname
OK

I was hoping that turning off the echo would eliminate all output up until the user list info. Obviously it didn't do that, and didn't even stop it from echoing the comands that were sent. So my question is, is there another easy way to suppress the output of an expect script? Or am I using stty wrong? Will I need to capture the output into Tcl variables in order to do what I want?


All times are GMT -5. The time now is 02:22 PM.