LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-29-2007, 11:52 AM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Unhappy avoid displaying errors while executing a script


Hi all,

I am running a script on bash shell, although it gives me the desired output, it displays some errors at the prompt like

this directory doesnt exists
unary operator
etc etc


Is there someway to avoid these errors ??
Its very annoying to have these errors while the script is executing.

Thanks
 
Old 10-29-2007, 12:16 PM   #2
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 17
Posts: 150

Rep: Reputation: 18
I would think that you would want to determine what lines/conditions are causing these errors and correct them (they are errors after all). If they are comming from lines that are executing something, but don't display anything that you need to see, you can just output everything from that command into /dev/null. But, without really knowing what the commands are, the entent of the script, and the desired output, I think that you'll be hard pressed to get a good answer. Kind of hard to work in the dark and all.
 
Old 10-29-2007, 12:17 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by vikas027 View Post
Is there someway to avoid these errors ??
Proper quoting, checking variables and testing?
 
Old 10-29-2007, 12:18 PM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
See: http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html for more info on redirecting stderr.
 
Old 10-31-2007, 01:27 AM   #5
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Hi all,

adding this line at top of the code helped
Quote:
exec 2>/dev/null
Thanks to all.
 
  


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
getopts - displaying warnings/errors when extraneous arguments are provided retrovertigo Programming 5 07-18-2007 03:44 PM
Bash script - executing a script through subdirectories bubkus_jones Programming 5 04-24-2006 05:05 PM
avoid been ask password by ssh with script? Chowroc Programming 6 02-14-2006 05:17 AM
executing a script!! vishamr2000 Linux - Security 5 07-29-2005 02:34 AM
How to avoid executing embeddbed file/link satimis Linux - Security 4 01-15-2004 08:23 AM

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

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