Download your favorite Linux distribution at LQ ISO.
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 11-01-2012, 04:19 AM   #1
Registered: Jan 2008
Posts: 75

Rep: Reputation: 15
Perl: suppress std output and std error


I am executing below perl command.

# perl -le '@tlinfo = `cat /tmp/hoststemp1`; foreach $j (@tlinfo) { chomp($j); $fqdn = qx(host $ > /dev/null && echo  $;$pingstatus = qx(ping -c 1 $fqdn > /dev/null 2>&1 && echo OK || echo Down);chomp($pingstatus);chomp($fqdn);print "$pingstatus";}' is alive
OK is alive

I do not want " is alive" this line to be printed. I am only interested in OK or Down output. even if I redirect output and error to /dev/null, this line is getting printed on std output.

Can anyone please help me
Old 11-01-2012, 06:22 AM   #2
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled

I don't know if I can help here. In perldoc for the qx command (which is very verbose) there is somthing explained about STDOUT and STDERR. It's available on the commandline with
perldoc -f qx


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
Template algorithm for std::vector and std::string CartmanYO Programming 4 09-08-2010 09:56 AM
[SOLVED] [bash] redirect all subsequent std output to file hashbang#! Programming 4 02-11-2010 05:01 PM
Don't know how to solve the Perl dependency (Getopt::Std) error that yum update gives info2share Linux - Software 2 07-07-2009 03:18 AM
Send string to std output without interpreting (script) ta0kira Programming 6 06-29-2005 08:50 AM
Ipchains/Tables logging output going to std out? WeNdeL Linux - General 5 01-18-2003 03:29 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:54 AM.

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