Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-05-2005, 04:51 PM   #1
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
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:

#!/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:

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

Escape character is '^]'.
sel 8767
login user password
p_id    c_id    ps      bs      pr      br      pl      ping    logintimeidletim
e       cprivs  pprivs  pflags  ip      nick    loginname
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?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Possibly the dumbest question I would ever expect to ask pyrael Linux - General 9 11-22-2005 06:52 AM
A question about expect. imjoe Programming 1 10-26-2005 05:42 AM
expect question reitzell Programming 1 11-20-2004 10:03 AM
Double and single quote, Question in expect evilchild Programming 4 08-22-2004 06:34 PM
"expect" shell beginner question, please help me out yuzuohong Linux - General 1 06-28-2003 02:17 PM > Forums > Non-*NIX Forums > Programming

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration