The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What is the proper way to combine C++ files (with g++) to avoid link (ld) errors? johnqsmith High Level Programming 1 03-17-2008 06:08 PM
Errors while Compiling a PC script. musavir19 High Level Programming 1 12-01-2005 12:02 PM
Displaying Script command with output JeDi Shell Programming and Scripting 5 04-30-2004 11:09 AM
checking for script errors Blip Shell Programming and Scripting 1 01-18-2004 02:20 PM
Errors while executing a.out nirthana High Level Programming 1 06-05-2003 03:05 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2007
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
Red face 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
  #2 (permalink)  
Old 10-29-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by vikas027 View Post
this directory doesnt exists
The code is trying to do something to, or to a file, in a directory that does not exist.

Quote:
unary operator
This means a "test" statement is failing, not just the condition not being met but the syntax is plain wrong.

To me, these errors mean there is something inherently wrong in the script that warrents investigation, not hiding under the carpet.
  #3 (permalink)  
Old 10-29-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,418
Fist solution (the worst) : Ignore errors and redirec error output to null device
At the begining of the script :
Code:
exec 2>/dev/null
Second solution (simply the best) : Correct errors in script.
A way to determine the origine of the error is to execute the script with the debug option -x

Jean-Pierre
  #4 (permalink)  
Old 10-29-2007
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
Smile

Quote:
Originally Posted by aigles View Post
Fist solution (the worst) : Ignore errors and redirec error output to null device
At the begining of the script :
Code:
exec 2>/dev/null
Second solution (simply the best) : Correct errors in script.
A way to determine the origine of the error is to execute the script with the debug option -x

Jean-Pierre

Thanks,
Both of you solutions working fine for me. Will try to debug the script.
Thank you so much
  #5 (permalink)  
Old 10-29-2007
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
Quote:
Originally Posted by porter View Post
The code is trying to do something to, or to a file, in a directory that does not exist.



This means a "test" statement is failing, not just the condition not being met but the syntax is plain wrong.

To me, these errors mean there is something inherently wrong in the script that warrents investigation, not hiding under the carpet.

hey, I just gave an example. I dont remember the exact error i am getting.
I ws just thinking if I could just avoid these kinda errors. I dont want to modify my script now.
thanks.
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0