New advice on error checking


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New advice on error checking
# 1  
Old 10-14-2013
New advice on error checking

HI All,

Whenever I write a shell script I always check if a command got executed successfully, even for the commands like cd, mv, rm and others, and even for the cases when there is ALMOST nothing to stop this commands from executing with success. so I am wondering if it is an overkill. I am thinking that there is always a chance that some directory might be accidently removed by a user/process and so on.

So I am just curious to hear about your approach to this.
Thanks
# 2  
Old 10-14-2013
When I write a script that only I will be running and I know that I will pay attention to any diagnostics my script produces and know how to fix it, I may omit some of the error checking.

When I provide sample code for the UNIX & Linux Forums, I occasionally put in error checking but generally assume that I'm writing samples rather than production code. If someone wants to put my samples into their production code, it is their job to make it bulletproof.

If I'm writing code for production use, I check the exit status of almost everything. (However, I seldom check the exit status of writing diagnostic messages. If they fail, what are you going to do -- write another diagnostic that will probably also fail???)

I pretty much follow the same philosophy when verifying that command line parameters and data being processed from user-supplied files are in the format needed to get the job done.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Advice on how to set up error handling

Hi Folks - I want to add error handling to a portion of a *.ksh, but I'm having difficulty doing so in an easily digestible way. Essentially, I want to echo weather it was successful or unsuccessful after each command. Here is the code I need to add error handling to: perl... (2 Replies)
Discussion started by: SIMMS7400
2 Replies

2. Shell Programming and Scripting

Error checking help.

I am currently wrapping up a assignment for one of my classes. I need help writing some error checking logic. The problems I am having are: keeping track of the records I have deleted and reported it back using echo. I have no idea how to do this. ensuring that line numbers fall... (1 Reply)
Discussion started by: Boltftw
1 Replies

3. Programming

C - advice how to catch some weird error

I have some unstable mistake in my program and out-of-idea how to catch it. I am looking for advice with a way to work it out! I have in a pretty complicated program (but one source file) set of int-counters - 15, if exactly. Lately, on final printout I have inpossible value (I am... (3 Replies)
Discussion started by: alex_5161
3 Replies

4. Programming

Error Checking

Hey guys i am facing a problem in my sql statement. I am trying to check if there is such a value in the database. Code: string NewMovie = "ww"; string queryText ; queryText = "Select * from movie_info WHERE movie_title = '"+ NewTitle +"'"; ... (1 Reply)
Discussion started by: gregarion
1 Replies

5. Shell Programming and Scripting

Error Handling -pls advice

Dear friends, I am using the below command in my unix script ----------------------------------------------- File_Name=`ls $CTRY*$DATE_SUFFIX*zip` --> Command-1 ..... if then unzip -a $File_Name -d $CTRY_DIR/$CTRY else echo "File for $CTRY dated $DATE_SUFFIX does not exist... (2 Replies)
Discussion started by: sureshg_sampat
2 Replies

6. Shell Programming and Scripting

some information on error checking

HI all; I am new to the KSH scripting and i was asked to do some error checking using KSH,in the log file, i donot know how to do error checking ,so please let me know some tips and the vague code if possible. Thanks in anticipation vinay (1 Reply)
Discussion started by: vinayrao
1 Replies

7. Shell Programming and Scripting

Need help with error checking

I am creating a script that will automatically use sftp to connect to a site and download a file, extract the tar and then delete the tar file once completed. What I am stuck on is the error checking for this process. Here is the code so far: Now this works for me as is, but i need... (0 Replies)
Discussion started by: xianoth
0 Replies

8. Shell Programming and Scripting

Error code checking

I'm trying to create a directory from my Perl script. Only if the there was an error I want to let the user know about it. So if the folder exists is ok. This is what I think should work: `mkdir log 2>/dev/null`; if($? == 0 || $? == errorCodeForFileExists) { everyting is fine } else {... (3 Replies)
Discussion started by: jepombar
3 Replies

9. Shell Programming and Scripting

Error Checking Problem

Here is my problem I'm designing a script that will have to accept user input from the command line using the read command. The problem is that I have to check the input which should be in the format of <first name> <last name> <phone number (8 digits long)> The input can also be ... (4 Replies)
Discussion started by: pokeycam
4 Replies

10. Shell Programming and Scripting

error checking in bash

Could someone please advise on a good way to implement error checking in a script? i am taking input from a file, iserting it's values into two commands and sending the output of each to seperate log files. i need to check those log files for for an occurance of 'error', stop the command if... (3 Replies)
Discussion started by: gubten
3 Replies
Login or Register to Ask a Question