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
# 8  
Old 12-17-2010
Look at my post #2. You didn't do correction1
Remove space before and after equal (=) sign
Code:
 
Nigh_Status=`db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`

And following mail command should have "Subject"
Code:
 
cat $MAILFILE | mail -s "This is test email" $mailto


Last edited by anurag.singh; 12-17-2010 at 12:30 PM..
# 9  
Old 12-20-2010
Still not getting the desired output after modifying the code:

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

---------- Post updated at 07:19 PM ---------- Previous update was at 07:17 PM ----------

There is a space before and after the = sign.but it is not showing here.

Last edited by Franklin52; 12-21-2010 at 07:42 AM.. Reason: Please use code tags, thank you
# 10  
Old 12-20-2010
There shoudn't be any space before and after equal sign.
And also correct the mail command. Put subject.
Both of these corrections are mentioned in post #8.
Please post the error you get after correcting it. Also post the final code (if error comes) along with errors
# 11  
Old 12-20-2010
from Nigh_Status = `db2
to Nigh_Status= 'db2.....

Get rid of the space between the equal sign and see if that works
# 12  
Old 12-20-2010
Quote:
Nigh_Status = `db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`
As previously advised, remove the space characters either side of the equals sign, then try the script and post the results.


Code:
Nigh_Status=`db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`


Afterthought:
We are all assuming that when you type the commands at the command prompt they work. i.e. You are scripting and existing working process.
Though I make no claims to being a "db2" expert I would be surprised if "db2" accepts SQL commands on the command line.
Should this guess prove to be correct, please post the command sequence from a relevant "db2" command line session which produces the required output.

Last edited by methyl; 12-20-2010 at 07:08 PM.. Reason: Afterthought
# 13  
Old 12-21-2010
Now, I am getting the following error message:
Code:
./nightly_jobs.sh: line 9: [: too many arguments

The 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=xyz@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 "This is test email" $mailto

Any modifications please ?

---------- Post updated at 12:10 PM ---------- Previous update was at 11:06 AM ----------

The 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=xyz@gmail.com
Nigh_Status=`db2 "select TYPE from ETL.LOCK where STATUS <> 0 and PROCESSINST like 'NIGHTLY%'"`
if [ $Nigh_Status="" ];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 "This is test email" $mailto


Last edited by Franklin52; 12-21-2010 at 07:43 AM.. Reason: Please use code tags
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