Nightly job error message when trying to execute script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Nightly job error message when trying to execute script
# 1  
Old 12-17-2010
Nightly job error message when trying to execute script

Hello All,

I am getting the following error message when trying to execute the following script.
Code:
AWK=/usr/bin/awk
TR=/usr/bin/tr
SED=/usr/bin/sed
CAT=/usr/bin/cat
MAILFILE=/home//nightly_jobs.tmp
mailto=xxx@gmail.com
 Nigh_Status = `db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`
 if [ $Nigh_Status -eq 0 ];then
  echo "Nightly Jobs - All Nightly jobs have been completed successfully for today" > $MAILFILE
 else 
  echo "Nightly Jobs - All Nightly jobs have been completed successfully for today except $Nigh_Status" > 
$MAILFILE
        fi
        cat $MAILFILE | mail -s $mailto
 
Error:
 
./nightly_jobs.sh
./nightly_jobs.sh: line 8: Nigh_Status: command not found
./nightly_jobs.sh: line 12: syntax error near unexpected token `newline'
./nightly_jobs.sh: line 12: `           echo "Nightly Jobs - All Nightly jobs have been completed successfully for today except $Nigh_Status" > '

Can you help me out in resolving this :

Thnaks.

Last edited by vbe; 12-17-2010 at 07:19 AM.. Reason: code tags please
# 2  
Old 12-17-2010
Try following:
Correction 1 (Remove space before and after equal (=) sign)
Code:
 
Nigh_Status=`db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`

Correction 2 (Looks like else block statement is in two lines, make it in one)
Code:
echo "Nightly Jobs - All Nightly jobs have been completed successfully for today except $Nigh_Status" > $MAILFILE

# 3  
Old 12-17-2010
Also ensure this line

Code:
MAILFILE=/home//nightly_jobs.tmp                 # 2 slash followed by home

R0H0N
# 4  
Old 12-17-2010
Code:
echo "Nightly Jobs - All Nightly jobs have been completed successfully for today except $Nigh_Status" > 
$MAILFILE

should be:
Code:
echo "Nightly Jobs - All Nightly jobs have been completed successfully for today except $Nigh_Status" >\
$MAILFILE

# 5  
Old 12-17-2010
I tried the following, bust still not successful.
Code:
./nightly_jobs.sh
./nightly_jobs.sh: line 8: Nigh_Status: command not found
./nightly_jobs.sh: line 9: [: -eq: unary operator expected
Send options without primary recipient specified.
Usage: mail [-BDFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr]
             [-r from-addr] [-h hops] [-A account] [-R reply-addr] to-addr ...
       mail [-BDeHiInNRv~] [-T name] [-A account] -f [name]
       mail [-BDeinNRv~] [-A account] [-u user]


Last edited by Scott; 12-17-2010 at 08:48 AM.. Reason: Code tags
# 6  
Old 12-17-2010
Please post the modified code
# 7  
Old 12-17-2010
The modified code is :
Code:
AWK=/usr/bin/awk
TR=/usr/bin/tr
SED=/usr/bin/sed
CAT=/usr/bin/cat
MAILFILE=/home//nightly_jobs.tmp
mailto=xxx@gmail.com
 Nigh_Status = `db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`
 if [ $Nigh_Status -eq 0 ];then
  echo "Nightly Jobs - All Nightly jobs have been completed successfully for        today"      > $MAILFILE
 else 
  echo "Nightly Jobs - All Nightly jobs have been completed successfully         for today except $Nigh_Status" > $MAILFILE
 fi
        cat $MAILFILE | mail -s $mailto

Still not getting the desired output.

Thanks

Moderator's Comments:
Mod Comment Still not getting the message about post formatting (code tags) either?

Last edited by Scott; 12-17-2010 at 12:24 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bsub job does not execute the script

Hello, When I'm trying to send bsub job using script that executes fine in command line, I get nothing. I do this for testing purposes, and the script scr_test is just one line: pwd > outfile So when I'm executing it in command line: $ ./scr_test it works fine producing the outfile with... (2 Replies)
Discussion started by: Sergey Aliev
2 Replies

2. Shell Programming and Scripting

how do i execute nohup and background job inside the korn script for db2

load_cursor_stmt() { ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file do echo "${file}" `nohup db2 -tvf "$file" \&` done }Error: ------- /admin/ddl/rmn01000/load_cursor5.sql /db/admin/ddl/rmn01000/load_cursor6.sql + read file + echo... (3 Replies)
Discussion started by: Hangman2
3 Replies

3. UNIX for Dummies Questions & Answers

System maintenance weekly job and welcome message

Since a few weeks I am playing with debian and now I have 2 questions. The first one: I want to create weekly a file to all user directories. I know that you have a cronjob to schedule it weekly. In this cronjob I have written the following line: df >> /home/%users/diskspace.txt I've... (1 Reply)
Discussion started by: iceqube
1 Replies

4. UNIX for Dummies Questions & Answers

schedule a job after a nightly reboot

Hello everyone, I want to schedule a job to run immediatly after a successful nightly reboot (at level 2). I have been looking at inittab file and vxvm-startup in /sbin/init.d and other files in init.d but I am still puzzled as where to actually start. I looked at the crontab to see how this... (2 Replies)
Discussion started by: rachael
2 Replies

5. Shell Programming and Scripting

How to capture actual error message when a command fails to execute

I want to capture actual error message in case the commands I use in my shell script fails. For eg: ls -l abc.txt 2>>errorlog.txt In this case I understand the error message is written to the errorlog.txt and I assume its bacause the return code from the command ls -l abc might return 2 if... (3 Replies)
Discussion started by: prathima
3 Replies

6. Shell Programming and Scripting

unable to execute background job

I am unable to execute the below command in background. Plz suggest. #> ./test input >out & 913618 + Stopped (SIGTTIN) ./test input >out & Suresh (1 Reply)
Discussion started by: suresh3566
1 Replies

7. Solaris

Installing gcc - recieve error message gcc : cannot execute

AIM- Install Oracle 11g on Solaris using VMWare Steps 1.Logged on as root 2.Created subfolders à /usr/local/bin & /usr/local/bin/gcc 3.Downloaded gcc & libiconv & unzipped them on my harddrive & burnt them on CD 4.Copied files from CD to /usr/local/bin/gcc 5.Terminal (root) à pkgadd -d... (8 Replies)
Discussion started by: Ackers
8 Replies

8. UNIX for Dummies Questions & Answers

a cron job needs a perl script to execute

Hello evreyone, this is my first post, and to say i'm new to this is an understatement. I know very little about perl scripts and hope some one can help me. i'm looking to get a script that a cron job can execute. what the script needs to to is 1) connect to a mysql database 2) go to a... (2 Replies)
Discussion started by: Exader
2 Replies

9. UNIX for Dummies Questions & Answers

cannot execute message

I am trying to install a piece of software using the provided install script, but when I run it, I get the following message: ./tem.sh: /export/home/data/SoftwareSource/TcEng2005SR1/install/jre/bin/java: cannot execute I navigated to that directory and tried to execute java and it returns the... (8 Replies)
Discussion started by: mncduffy
8 Replies

10. UNIX for Dummies Questions & Answers

CRON job to execute all scripts in a directory

Hi everyone: I'm trying to make a CRON job that will execute Fridays at 7am. I have the following: * 7 * * 5 I've been studying up on CRON and I know to have this in a file and then "crontab filename.txt" to add it to the CRON job list. The CRON part I believe I understand, but I would... (6 Replies)
Discussion started by: Annorax
6 Replies
Login or Register to Ask a Question