avoid displaying errors while executing a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting avoid displaying errors while executing a script
# 1  
Old 10-29-2007
Power 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  
Old 10-29-2007
Quote:
Originally Posted by vikas027
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  
Old 10-29-2007
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  
Old 10-29-2007
Quote:
Originally Posted by porter
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.
# 5  
Old 10-29-2007
Bug

Quote:
Originally Posted by aigles
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to avoid errors when moving files in a bff?

I am building a bff using mkinstallp. My template file is : Package Name: svr_exForum Package VRMF: 7.2 Update: N Fileset Fileset Name: svr_exForum.rte Fileset VRMF: 7.2 USRLIBLPPFiles Pre-installation Script: /lppdir/lpp/exForum/F_pre_i ... (2 Replies)
Discussion started by: kevinl
2 Replies

2. Shell Programming and Scripting

shell_script showing errors in the below mentioned script while executing in linux

code: IMAGE=$imgvalue; if then echo DO=ABC; elif then echo DO=ETC; elif then echo DO=XYZ; else echo "$imgvalue is unsupported"; exit 1; fi in above script IMAGE=1 , IMAGE=2, IMAGE=3 whatever may be the value i have assigned it's showing only DO=ABC other conditions... (7 Replies)
Discussion started by: saku
7 Replies

3. Shell Programming and Scripting

Bash script errors when executing

I'm working on a script that will search through a directory for MKV files and remux them to MP4. I found a few other scripts around the net that do this, but they all have limitations that don't always get the job done. The main limitation I've found is that most scripts look for the video track... (2 Replies)
Discussion started by: rayne127
2 Replies

4. Shell Programming and Scripting

Avoid interaction into script

Sorry for my english! I'm using Debian squeeze and for an assignement, i have create 2 virtual pdf cups printers. Both are working very well. To test the different administion command; i try to disable one of the printer and move his queue file to the second one. I'm able to do it easily. ... (4 Replies)
Discussion started by: lyapma
4 Replies

5. Shell Programming and Scripting

perl script to send an email executing with errors

Hello , i am using RHEL5 , i have got a perl script that executes and sends an email correctly if i run it with ./sendemail.sh command. This is the script below #! /usr/bin/perl use Net::SMTP; print "starting email send ."; $smtp = Net::SMTP->new("192.168.0.1");... (2 Replies)
Discussion started by: kabazzi
2 Replies

6. Solaris

Any way to avoid these errors?

Hello, this is solaris 10 on SF v440, I know below errors might go away if I put a new PS or put the original one back in socket but is there any other way to stop these errors from appearing in /var/adm/messages ? I do not want to put the failed PS1 in socket neither do we want to spend on... (5 Replies)
Discussion started by: upengan78
5 Replies

7. UNIX for Dummies Questions & Answers

Errors while executing mysql cmds in SUn solaris server

Hi All, I am using mysql at sun solaris unix(Hp) server. I logged into mysql server with root as user. its logged in properly. Then i used 'show databases' mysql command. its display all the available databases. for example mysql > show databases; It displayed as follows. exampledb1... (1 Reply)
Discussion started by: dbsurf
1 Replies

8. Shell Programming and Scripting

Errors while executing cmds in sun solaris

Hi All, I am using mysql at sun solaris unix(Hp) server. I logged into mysql server with root as user. its logged in properly. Then i used 'show databases' mysql command. its display all the available databases. for example mysql > show databases; It displayed as follows. exampledb1 ... (1 Reply)
Discussion started by: dbsurf
1 Replies

9. Programming

What is the proper way to combine C++ files (with g++) to avoid link (ld) errors?

Problem background: gcc v 4.1 2 .cpp files, 2 .h files Files: main.cpp a.cpp a.h b.h Organization: main.cpp includes a.h (because it calls a.cpp code) a.cpp includes a.h a.h includes b.h (because a class in a.h uses a b.h class) There is no inheritance between a.h or b.h or any of... (1 Reply)
Discussion started by: johnqsmith
1 Replies

10. Programming

Errors while executing a.out

Hi, I tried a simple hello.cc program in Unix. - Compiled with no errors - Created a.out successfully - While executing a.out, following error message appeared " ld.so.1:a.out fatal: libstdc++.so.2.10.0: Open failed: No such file or directory Killed" ... (1 Reply)
Discussion started by: nirthana
1 Replies
Login or Register to Ask a Question