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

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, 06:22 AM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

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



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

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

All times are GMT -5. The time now is 07:48 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