Sponsored Content
Top Forums Shell Programming and Scripting korn shell script executed with error Post 302498093 by beooi on Saturday 19th of February 2011 09:14:33 AM
Old 02-19-2011
Hi there, thanks and appreciate your reply. But there is #!/bin/ksh in the script, is there anything wrong in the script?
Code:
  
#!/bin/ksh
# ------------------------------------------------------------------
# seaoe_send_mail
#  This script will mail a file to  a distribution list.
#   First parameter = email_address $5
#   2nd parameter = filename  $6
#   3rd parameter = email subject line $7
#
# 07-apr-04 cat remove notes from email address.
# 02-jun-05 cat upgrade to 11i 
# 15-jul-05 cat change /usr/ucb/mail to /usr/bin/mail
# ------------------------------------------------------------------
# Set the variable $TOPDIR, which is the directory above the
# /bin directory where this shell script resides.  This module
# assumes a file structure of:
#  $TOPDIR/bin - shell scripts and other control code
#  $TOPDIR/srw - reportwriter report .rdf files
# ------------------------------------------------------------------
if [[ ${0%/*} == $0 ]]
then
        TOPDIR=$(pwd)
else
        TOPDIR=${0%/*}
fi
TOPDIR=${TOPDIR%/*}

# ------------------------------------------------------------------
# Initialize variables.
# ------------------------------------------------------------------
IT_PERSON="beeean.ooi@.seagate.com"
#IT_PERSON="nilesh.shah@seagate.com"
message="Unexpected Shell error in $0"
error_subject="Error in process $$ - $0"
# ------------------------------------------------------------------
# This function will run whenever exit is called, whether from this
# script, the errorexit or an interrupt.  It updates the log file
# and cleans up the temporary error file.
# ------------------------------------------------------------------
function normalexit {
  print " "
  print "Process $1 complete at $(date)"
  print " "
}
# ------------------------------------------------------------------
# This function is used to exit gracefully if there are errors.
# It mails the standard error message sent to the error file, along
# with the last value of $message (usually STDIO).  It also writes
# the full message sent via E-mail to STDIO for log and test purposes.
# ------------------------------------------------------------------
function errorexit {
# write the error message to STDOUT
  print "$1"
# Mail the error to the responsible I.T. person
  print "$1" | mail -s "$error_subject" "$IT_PERSON"
  exit 1
}
# ------------------------------------------------------------------
# Trap errors and exits from any source (exit commands or interrupts)
# ------------------------------------------------------------------
trap 'errorexit "$message"' ERR
trap 'normalexit $$' EXIT
# ------------------------------------------------------------------
# Submitted from Concurrent Manager - Oracle provides the argument
# as a huge string of the form:
#   'COMMAND FCP_???=val ... "parameter1" "parameter2"'
# print ${1##*FCP_LOGIN=} | nawk '{print $1}' | sed 's/"//g'
#    strips the login/password from the Concurrent Manager parameter
# print ${1##*FCP_} removes all FCP_ parameters except the final one
#   '???=val "parameter1" "parameter2"
# therefore after the print, the key parameters can be extracted
# from the second and third columns of the print.
# ------------------------------------------------------------------
  
  emdist=$5
  ffile=$APPL_DATA/tmp/$6
  subject=$7
  outpath=$APPL_DATA/$APPLOUT
# ------------------------------------------------------------------
# This process assumes that all E-mail addresses
# should end in @seagate.com.  It will add to any
# path that does not have it.  Any addresses that do not go to
# non-Notes destinations will fail, so there is no way for an
# E-mail to make it to the Internet from this process
# ------------------------------------------------------------------
#        emdist=$(print "$emdist" | sed 's/, /,/g')
#        emdist=$(print "$emdist," | \
#        sed 's/,/@seagate.com,/g' | \
#        sed 's/@seagate.com@seagate.com,/@seagate.com,/g' | \
#        sed 's/,@seagate.com,/,/g')
#        emdist=${emdist%,}
   print "Attempting to mail to:
$emdist"

#
# This code is added by Nilesh P Shah on 19/03/2004
#
line_temp=`wc -l $ffile`
line_cnt=`echo $line_temp | cut -f1 -d' '`
if [ $line_cnt -gt 1 ] 
then
{
  echo " "
  echo " "
  echo "Sending CRU mail with an ".DAT" file attachment."
  echo ""
  echo ""
  echo "*********************************"
  echo "Shipping Freight Term Audit Report"
  echo "*********************************"
  echo ""
  echo "" 
  uuencode $ffile repricing_report.csv
} | mail -s "$subject" $emdist 
else
{
      echo " "
      echo " "
      echo "    ***  NO DATA SELECTED  ***   "
      echo ""
      echo ""
      echo "*********************************"
      echo "Shipping Freight Term Audit Report"
      echo "*********************************"
      echo ""
      echo "" 
      
} | mail -s "$subject" $emdist 
fi
 
#        /usr/ucb/mail \
#                -s "$subject" \
#                 $emdist <$ffile

print " "
print "Report mailed to the address list"
print " "
exit 0


Last edited by fpmurphy; 02-19-2011 at 12:33 PM.. Reason: fixed code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script doesn't get executed using crontab

I have the following crontab entry to run a shell script for every 30 minutes of every day: 30 * * * * $HOME/main.sh > $HOME/main.log 2>$HOME/error.log after I created the crontab file I have also done: $crontab my_crontab I also check to make sure it exists, by using the following... (11 Replies)
Discussion started by: radhika
11 Replies

2. AIX

Help - Need simple example of VI executed in shell script

Please help - I have seen others ask this question but I need a simple example of using vi in a shell script. Once I enter VI the shell script does not execute the next commands until I q!. I invoke VI and start the edit process. I want to go to the third line and replace a character with a new... (2 Replies)
Discussion started by: corsart
2 Replies

3. Shell Programming and Scripting

Korn Shell Script to find out error in logfile

Hi All, I am new to this forum as well as to unix scripting. Can you please help me to create a korn shell script to find out errors in logfiles and get the name of that logfile ( which is having error) in email and email it to me? (2 Replies)
Discussion started by: jithu
2 Replies

4. Shell Programming and Scripting

help with shell script executed by php.

I made a shell script to execute a server in screen mode. # start server screen -d -m -S Test ./application echo "Program Started Successfully" than I'm executing it from php by echo shell_exec('/home/script.sh'); and it is giving me this error. "cannot make directory... (1 Reply)
Discussion started by: dmallia
1 Replies

5. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

6. Shell Programming and Scripting

Shell script not getting executed

Hi As per my requirement when I run . ./file.sh am getting the following error -bash:ELF: command not found when i execute as ./file.sh it is getting executed.How to resolve this. Thanks in advance. (3 Replies)
Discussion started by: pracheth
3 Replies

7. Shell Programming and Scripting

Multiple shell scripts executed in one script

Hi every one, i am new to shell script. my people given a task to write a shell script that should execute number of shell scripts in that. in that, if any shell script is failed to execute, we have to run the main script again, but the script should start execute from the failed script only.. it... (1 Reply)
Discussion started by: Madhu Siddula
1 Replies

8. Shell Programming and Scripting

Multiple shell scripts executed in one script

Hi every one, i am new to shell script. my people given a task to write a shell script that should execute number of shell scripts in that. in that, if any shell script is failed to execute, we have to run the main script again, but the script should start execute from the failed script only.. it... (6 Replies)
Discussion started by: Madhu Siddula
6 Replies

9. Shell Programming and Scripting

awk command not getting executed in shell script

I am able to execute awk command from shell prompt. but the same command is not getting executed when written and run in a bash script the command from bash cmd prompt. awk '/world/{for (i=2; i<NF; i++) printf $i " "; print $NF}1' myfile >tmp$$ ; mv tmp$$ myfile file: # hello world my... (4 Replies)
Discussion started by: ashima jain
4 Replies

10. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies
All times are GMT -4. The time now is 10:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy