How not to show messages?

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2009
Posts: 17
Reputation: darangho is an unknown quantity at this point 
Solved Threads: 0
darangho darangho is offline Offline
Newbie Poster

How not to show messages?

 
0
  #1
Aug 25th, 2009
Hi all
I just have questions about
how not to show messages after you execute a certain command.

for example whenever you execute "which xxx"
there will always be a message on the terminal
saying its path or command not found will be written.

is that possible to write a shell script file
without showing these kind of messages?

Thanks!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,327
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 599
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: How not to show messages?

 
1
  #2
Aug 25th, 2009
Send stdout and stderr to /dev/null:
  1. sk@sk:~$ which bash
  2. /bin/bash
  3. sk@sk:~$ which bash >> /dev/null 2>&1
  4. sk@sk:~$

You can still access the return value which is usually why this is done. Here is an example:
  1. sk@sk:~$ which bash >> /dev/null 2>&1
  2. sk@sk:~$ echo $?
  3. 0
  4. sk@sk:~$ which asoija0cjas9cuasc >> /dev/null 2>&1
  5. sk@sk:~$ echo $?
  6. 1
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: darangho is an unknown quantity at this point 
Solved Threads: 0
darangho darangho is offline Offline
Newbie Poster

Re: How not to show messages?

 
0
  #3
Aug 25th, 2009
Thank you very much
problem solved!

Originally Posted by sknake View Post
Send stdout and stderr to /dev/null:
  1. sk@sk:~$ which bash
  2. /bin/bash
  3. sk@sk:~$ which bash >> /dev/null 2>&1
  4. sk@sk:~$

You can still access the return value which is usually why this is done. Here is an example:
  1. sk@sk:~$ which bash >> /dev/null 2>&1
  2. sk@sk:~$ echo $?
  3. 0
  4. sk@sk:~$ which asoija0cjas9cuasc >> /dev/null 2>&1
  5. sk@sk:~$ echo $?
  6. 1
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,327
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 599
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: How not to show messages?

 
0
  #4
Aug 25th, 2009
Please mark this thread as solved as you have found an answer to your question and good luck!
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC