Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 15th, 2012, 10:11 AM
sujoydc sujoydc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 14 sujoydc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 41 m
Reputation Power: 0
Send a message via Yahoo to sujoydc
/dev/null not working

Hi,

I have a statement like this:

COMMAND="which java"
RUN_COMMAND=`eval "$COMMAND"` > /dev/null
echo "Output of the command:"$RUN_COMMAND


Here if java doesn't exist in the system it throws some output like
no java in (/usr/local/bin:/usr/bin
And I don't want this to be on the console.
So, even after redirecting the output to /dev/null it's still sending the output to the console.
Any idea?

Reply With Quote
  #2  
Old May 15th, 2012, 10:49 AM
sujoydc sujoydc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 14 sujoydc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 41 m
Reputation Power: 0
Send a message via Yahoo to sujoydc
Well I got the answer...

COMMAND="which java"
RUN_COMMAND=`eval "$COMMAND"" 2> /dev/null"`
echo "Output of the command:"$RUN_COMMAND

Reply With Quote
  #3  
Old May 19th, 2012, 09:15 PM
Squ3lch Squ3lch is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 11 Squ3lch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 2 m 28 sec
Reputation Power: 0
Yes, the "2>" directs stderr to /dev/null where ">" redirects standard output.

Reply With Quote
  #4  
Old May 20th, 2012, 06:29 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 41 m
Reputation Power: 1485
Quote:
Originally Posted by Squ3lch
Yes, the "2>" directs stderr to /dev/null where ">" redirects standard output.

More to the point, the redirection was moved to within the command ticks. Where it was in the original only related to the variable setting command, not the running of the command. The change to stderr (file 2) is what made the error message be thrown to the bit bucket.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > /dev/null not working

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap