LinuxQuestions.org
Visit Jeremy's Blog.
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 11-01-2012, 05:19 AM   #1
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 68

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


Hello,

I am executing below perl command.

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

I do not want "lonlXXX.mydomain.com 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
--Ravi
 
Old 11-01-2012, 07:22 AM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Hi,

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
Code:
perldoc -f qx
Markus
 
  


Reply


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 10:56 AM
[SOLVED] [bash] redirect all subsequent std output to file hashbang#! Programming 4 02-11-2010 06: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 04:18 AM
Send string to std output without interpreting (script) ta0kira Programming 6 06-29-2005 09:50 AM
Ipchains/Tables logging output going to std out? WeNdeL Linux - General 5 01-18-2003 04:29 AM


All times are GMT -5. The time now is 01:13 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration