LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-03-2009, 02:47 PM   #1
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Expect: Prevent output from spawned process to appear on stdout


I have this expect process:

Code:
spawn -noecho telnet my.host.com
 expect {
        connected
    }
Now I get this string "connected" which is produced by the telnet server in $expect_out(buffer) which is fine.

Unfortunately, the same output is copied to the console where I started my expect script from. So the command that I send is surpressed with the -noecho flag, but whatever comes back is echoed.

I don't like that, the only solution is to redirect all output to /dev/null like:
Code:
expect -f myscript > /dev/null
But that is not what I want either, because then I don't see my own messages.

Any idea how to surpress all output produced by the spawned process?

jlinkels
 
Old 07-13-2009, 10:53 AM   #2
cejennings_cr
LQ Newbie
 
Registered: Jul 2006
Posts: 5

Rep: Reputation: 0
You might send it to the background by placing NOHUP at the beginning and the ampersand (&) at the end of command:

spawn -noecho NOHUP telnet my.host.com &

That should send the spawned session to the background and suppress output to the terminal.
 
Old 07-23-2009, 10:04 AM   #3
pdavis057
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 1
Did you try "log_user 0" ? By default, the send/expect dialogue is logged to stdout. Logging is disabled by the command “log_user 0” and reenabled by “log_user 1” (the default).

Zig
 
Old 08-12-2009, 09:20 PM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Yes, log_user 0 does it. Not quite apparent from the documentation.

Thanks

jlinkels
 
  


Reply



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
expect says it cant send the string to the spawned command exceed1 Programming 0 01-17-2009 06:51 AM
vpnc spawned from "expect" killed upon exit saravkrish Linux - General 1 01-29-2007 08:17 PM
XFce New window focus on spawned process xray_fl Linux - Software 0 05-12-2005 07:03 AM
how to output stdout to a file SciYro Linux - Newbie 4 02-25-2004 05:08 PM
stdout for a background process GOLDF1NG3R Linux - General 3 11-14-2001 01:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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