Please review error routines in my ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please review error routines in my ksh script
# 1  
Old 07-22-2012
Please review error routines in my ksh script

The script distributes files from an AIX server using iether ftp or sftp depending on the constraint of the destination server. I am interested in having the error checking routine critically reviewed. I will only include an excerpt from the script concerning error trapping: (where $FTP_OUT is the log captured for either an "ftp" or an "sfpt" transfer)
Code:
Check_for_errors()
{
      set -x


      RESULT=`egrep -c "not found|No such|refused|failed|error|timed out|not exist|denied|Connection closed|STOR fails|not authorized|timeout|Not connected" $FTP_OUT`
      if [[ ! -s $FTP_OUT ]] ; then
         error_reporting
         ERROR_MSG="** FAILURE **"
         echo "    No $ftpflag log file produced" >> $TEMP_LOGF
         echo "    Abandoning transfer. " >> $TEMP_LOGF
      elif [[ $RESULT -gt 0 ]] ; then
         # The existence of "Transfer Complete" doesn't guarentee a successful result, however it must be present for a successfil result.
         # Checking for it's existance excludes the possibility of a null log file or an unknown error type.
         error_reporting
         ERROR_MSG="** FAILURE **"
      else
         echo "    FTP Success for interface $ftpflag ::: ${ftpfile} " >> $TEMP_LOGF
      fi
      rm -f $FTP_CMD
      rm -f $FTP_OUT
}


Last edited by Franklin52; 07-24-2012 at 08:27 AM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 07-22-2012
This seems OK to me!! Did you try out?
# 3  
Old 07-22-2012
Yes, I've tried it and it works, but how do I know I've covered every error possibility. Say, I missed an error in the "egrep" list, The routine might fail to detect an error.
# 4  
Old 07-22-2012
In that case, force that to fail in all terms (Trial & Error). Else, echo the line you get after the transfer, let the user review and proceed! Smilie
# 5  
Old 07-23-2012
Actually, the routine is below, posted a different version:

Code:
Check_for_errors()
{
      set -x

      RESULT=`egrep -c "not found|allow|permissions|No such|refused|failed|error|timed out|not exist|denied|Connection closed|STOR fails|not authorized|timeout|Not connected" $FTP_OUT`
      if [[ ! -s $FTP_OUT ]] ; then
         error_reporting
         ERROR_MSG="** FAILURE **"
         echo "    No $ftpflag log file produced" >> $TEMP_LOGF
         echo "    Abandoning transfer 4. " >> $TEMP_LOGF
      elif [[ $RESULT -gt 0 ]] ; then
         error_reporting
         ERROR_MSG="** FAILURE **"
      else
         echo "    FTP Success for interface $ftpflag ::: ${ftpfile} " >> $TEMP_LOGF
      fi
      rm -f $FTP_CMD
      rm -f $FTP_OUT
}

Thanks

Last edited by Franklin52; 07-24-2012 at 08:27 AM.. Reason: Please use code tags for data and code samples, thank you
# 6  
Old 07-23-2012
You could use ignore case option too!!
# 7  
Old 07-23-2012
Thankyou for your comments pikK45. I don't have the luxury of trial and error, other than the extensive testing I've done in an attempt to get all the "error texts". It's a batch process.
Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error in ksh script: missing right bracket

I have no idea how to write ksh script, but i'm really in need of help with this. I using fedora 30 and in attempt of runnig attached script i getting those errors, i solved first error by removing excess bracket, but i do not know what should i do with other. Pls sorry for trash post. (8 Replies)
Discussion started by: NullPtr
8 Replies

2. Shell Programming and Scripting

ksh Script - Syntax error `done' unexpected

Hello, I am working on my first ksh script to review daily reports. The script uses different functions to check different types of reports in csv format. A control file gets read in with information regarding the report, other info, and the function to use. When I run the script I get the... (4 Replies)
Discussion started by: bot9196
4 Replies

3. Shell Programming and Scripting

Ksh Shell Script Error

Hi, While running below code i am getting error as below 0403-004 Specify a parameter with this command. Please look it below code and let me know about if condition. Code is As below #!/usr/bin/ksh Infa_Src_Dir=$DIR/SrcFiles/pp Load_Info_Lst_Path=$DIR/SrcFiles/pp... (1 Reply)
Discussion started by: samadhanpatil
1 Replies

4. Shell Programming and Scripting

assistance needed to add 2 other routines to my script

Hello guys, In my script, I need to add two other routines where I Manipulate the files with a 'x' The routine looks at CLI named qip-getobjectprof that references a input file named hosts_list.txt Then I use the CLI named qip-setobject to set the orignal name with an 'x'and move the... (3 Replies)
Discussion started by: richsark
3 Replies

5. Shell Programming and Scripting

Please review script for search in all files

I have written a little script to scan users home directories for certain commands located inside a file. The script is setup to include a small help section and allows for passing a username argument to override scanning of all users home directories. A lot of searching and trial and error has... (7 Replies)
Discussion started by: bkeep
7 Replies

6. Shell Programming and Scripting

a shell script for review.

I have written a bit of shell that lets our company check all our SSL certs. the aim is to have a list of servers and run this check from cron once a week. Our managers have decided that we will not run BASH, so it has been written in /bin/sh and only needs openssl, no perl, no bash, no extra... (8 Replies)
Discussion started by: robsonde
8 Replies

7. Shell Programming and Scripting

can we use routines of datastage in unix script

Hi all, My aim is to get the log details of datastage job using unix scipt. we know that DSjob are used to get the log details from datastage universe through the adminstrator.can we call that DSjob rountine in our unix script. Thanks in advance Regards, NimmyRaju:) (0 Replies)
Discussion started by: nimmyraju
0 Replies

8. Shell Programming and Scripting

Please, review script.

Hi guys, I 've been brewing this shellscript, but I can't test it until next tuesday. In the meantime I am too curious wether it will work or not, so I'd like to hear your comments. Background: I want to watch the user quota for mailboxes in various email-domains on a IMAP-server. I have... (1 Reply)
Discussion started by: algernonz
1 Replies

9. Shell Programming and Scripting

Review the Shell Script

Hi, I want to copy all the log file except current date log from one server to another server. Log File will be like this LOGNIG_08_11_2008*.log For this cd /test/log date -d '1 day ago' "+%d_%m_%Y" -->This command gives previous day scp LOGSNIG_date -d '1 day ago' "+%d_%m_%Y"... (2 Replies)
Discussion started by: srinivasvandana
2 Replies

10. Shell Programming and Scripting

error in ksh script

Hi, i am facing an error in the following script in the korn shell but in bash it is working , can any help me to convert the below script to korn shell script without errors. echo 123.4566 | bc -l | awk -F '.' '{ print $1; exit; }' Thanks in advance kamal (5 Replies)
Discussion started by: G.K.K
5 Replies
Login or Register to Ask a Question