LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-02-2005, 09:35 AM   #1
Quantum0726
Member
 
Registered: Dec 2003
Location: Milwaukee, WI
Distribution: Gentoo
Posts: 39

Rep: Reputation: 15
Bash scripting (hide sterr messages)


Hi,
I'm writing a bash script and having two problems. Both of which could be solved (I think) in the same way, I'm just not sure how to. I am running an external command and it's writing a message to /dev/stderr. In my bash script I want to capture that message and not let it display to the screen. I know for /dev/stdout I can just use the '>' operator to capture it or send it to /dev/null, but this does not capture anything going to /dev/stderr as far as I can tell. Any ideas on how I can do this?

Thanks much!
 
Old 06-02-2005, 10:10 AM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,333

Rep: Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547Reputation: 547
"I'm writing a bash script and having two problems. Both of which could be solved (I think) in the same way, I'm just not sure how to. I am running an external command and it's writing a message to /dev/stderr. In my bash script I want to capture that message and not let it display to the screen. I know for /dev/stdout I can just use the '>' operator to capture it or send it to /dev/null, but this does not capture anything going to /dev/stderr as far as I can tell. Any ideas on how I can do this?"

You route error messages using the number 2.
2> /dev/null

You route standard messages using the number 1.
1> /dev/null

If you do not specify a number then the default is 1.
> /dev/null

----------------------
Steve Stites
 
Old 06-07-2005, 08:05 PM   #3
Quantum0726
Member
 
Registered: Dec 2003
Location: Milwaukee, WI
Distribution: Gentoo
Posts: 39

Original Poster
Rep: Reputation: 15
Thanks Steve! That works perfectly.

I had always seen that as a way of logging the startkde command, but never really knew what it meant.
 
  


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
How To Hide Kernel Messages With Graphics dragoncity99 Slackware 3 03-18-2005 08:11 PM
BASH Scripting ? eroica Programming 3 06-07-2004 07:51 PM
need help with bash scripting rich2oo1 Programming 2 12-17-2003 12:50 PM
bash scripting - suppress error messages? brian0918 Programming 2 06-19-2003 11:16 AM
How to hide server -220 messages ximar Linux - Security 4 04-19-2003 11:41 AM

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

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