Script execution fails


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script execution fails
# 1  
Old 06-03-2013
Script execution fails

hi,
i am trying to run this script, getting below error, can some one help me in this

Code:
Error: -bash: on_failure.sh: line 23: syntax error: unexpected end of file

========================================================
# CHANGE HISTORY
#
# YYYYMMDD Change by     Desription
# -------- ------------- -------------------------------------------------------
# 20130427        send email to example1@.com if user is asm_admin
#                        also add logging info
# ------------------------------------------------------------------------------
MAIL_TO=`echo $1 | sed s/\'//g`
FLOWCHART_NAME=`echo $2 | sed s/\'//g`
if [ "$MAIL_TO" = "asm_admin" ]; then
  MAIL_TO="admin@web.com"
fi
FROM_HOSTNAME=`hostname`
# log the flowchart process that calls this trigger
LOG_PREFIX="(`date`) [PPID:${PPID} PID:$$]"
FLOWCHART_PS=`ps -ef | grep " $PPID " | awk '{ if ( $2 == '$PPID' ) print }'`
YYYYMMDD=`date +"%Y%m%d"`
OUTPUT_LOG=/u01/partitions/scripts/EmailNotificationTriggers/logs/on_failure_${YYYYMMDD}.log
echo "$LOG_PREFIX  The parent flowchart process: \"$FLOWCHART_PS\"" >>$OUTPUT_LOG 2>&1
echo "$LOG_PREFIX  Notify ${MAIL_TO} of flowchart failure: ${FLOWCHART_NAME}"  >>$OUTPUT_LOG 2>&1
echo "Login to system to verify cause of the failure. \n\n${FLOWCHART_PS}" | 
 mailx -r "system_${FROM_HOSTNAME}_NoReply@web.com" -s "Flowchart run failed: $FLOWCHART_NAME" $MAIL_TO   >> $OUTPUT_LOG 2>&1

Thanks
SZS

Last edited by jim mcnamara; 06-03-2013 at 01:35 PM.. Reason: Please use code tags
# 2  
Old 06-04-2013
Try it with a line continuation:
Code:
echo "Login to system to verify cause of the failure. \n\n${FLOWCHART_PS}" | /
mailx -r "system_${FROM_HOSTNAME}_NoReply@web.com" -s "Flowchart run failed: $FLOWCHART_NAME" $MAIL_TO   >> $OUTPUT_LOG 2>&1

Or put the last 2 lines on 1 line:
Code:
echo "Login to system to verify cause of the failure. \n\n${FLOWCHART_PS}" | mailx -r "system_${FROM_HOSTNAME}_NoReply@web.com" -s "Flowchart run failed: $FLOWCHART_NAME" $MAIL_TO >> $OUTPUT_LOG 2>&1

# 3  
Old 06-04-2013
Is anything being written into the log file before you get the diagnostic from bash?

Exactly what are the operands to this script when it fails?

Does it always fail, or does it only fail when it is invoked with certain operands?

What OS are you using?

Not to disagree with spacebar, but bash shouldn't behave differently if the script is left as is, if a backslash is added to the end of the next to the last line, or if the last two lines are joined into a single line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find command fails mid-way during execution

I wish to search for a particular string say "Yellow_Colors" in all files in all folders in the current directory. Below is the command I use: find ./ -type f | xargs grep -i "Yello_Colors"However, my command does not traverse all files and folders and errors out mid-way with the below error... (7 Replies)
Discussion started by: mohtashims
7 Replies

2. HP-UX

./ignite.sh script fails after 5 seconds

Hello, I am trying to run a make_net_recovery Ignite for a server in a 2 node cluster . But I do get some issues. VG "/dev/vg59" is not defined in file "/etc/lvmtab". VG "/dev/vg59" is not defined in file "/etc/lvmtab_p". save_config: Error - vg00 not in the volume/disk group ERROR: ... (0 Replies)
Discussion started by: velde_van_der_a
0 Replies

3. Shell Programming and Scripting

Execute shell script even if the first script fails

All, I executing a perl script and shell script from a master shell script. i will execute the perl script first and have to execute the shell script after the completion of perl execution. Below is the code i use for it, script_root='/dev/scripts' /usr/bin/perl -S $script_root/test.pl;... (5 Replies)
Discussion started by: vel4ever
5 Replies

4. Shell Programming and Scripting

Stop execution of script if some condition fails

After my if condtion give rusult true then script should stop execution. Please advice...Thnaks in advance (1 Reply)
Discussion started by: vivek1489
1 Replies

5. Shell Programming and Scripting

crontab fails to run script

OS is Ubuntu 8.04.3. When I run the command: /usr/bin/syslogMailer < /etc/syslog.pipes/criticalMessagesFrom a bash shell it works and i receive an email as per the script however when run from crontab it does not work. Can anyone explain why and how to fix it? /usr/bin/syslogMailer... (4 Replies)
Discussion started by: jelloir
4 Replies

6. Shell Programming and Scripting

why shell script fails?

hi , i m trying to run a shell script automatically , some time it works fine but some time it fails , what could be the problem . If anybody have an idea about this problem then reply . Thanks in advacne (4 Replies)
Discussion started by: tahir23
4 Replies

7. UNIX for Advanced & Expert Users

why script fails sometime?

Hi, I am trying to run a shell script on solaris,some time it works fine and some times it fails unexpectedly. There is a script called "autostart.sh" which automatically starts the Application server but some times the script fails to strat the application server. can anyone tell me what... (10 Replies)
Discussion started by: tahir23
10 Replies

8. Shell Programming and Scripting

why shell script fails

hi .. I have automate some process on unix through sehll script . but i don't know there is some problem in scripts, some time shell script works and some time it fails. so my query is that "Why shell script fails some times?" thanks (4 Replies)
Discussion started by: tahir23
4 Replies

9. Shell Programming and Scripting

Scripts fails if you change its code during the execution.

So a script is working properly (tested many times) , then you add a new fine piece of code ,finaly its fails generally with a syntax error at the last line of the script. :confused:... does anybody why this happens? >uname -a HP-UX test... (4 Replies)
Discussion started by: Klashxx
4 Replies

10. Shell Programming and Scripting

Script fails

Hi, I am trying to install a package on solaris and one of the packaging scripts fail unexpectedly. There is a script called "checkinstall" which checks for the /opt space and aborts the installation if /opt is less than 100MB. In my case, even if /opt has enoguh space, the script fails. ... (8 Replies)
Discussion started by: JStone
8 Replies
Login or Register to Ask a Question