Staus of Executed Scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Staus of Executed Scripts
# 8  
Old 05-12-2005
Ice,

If you are executing temp log files for this, there is no need to create /tmp/c.complete.

Change your scenario as,
a.sh
...
...
touch /tmp/a.complete

b.sh
#! /bin/ksh
[ ! -f /tmp/a.complete ] && exit
...
...
rm -f /tmp/a.complete
touch /tmp/b.complete

c.sh
#! /bin/ksh
[ ! -f /tmp/b.complete ] && exit
...
...
rm -f /tmp/b.complete

But default way is to $? to get the status of script execution. Return on every script with success and failure with exit 0 or exit 1 so that you can keep track with $? variable.

sh a.sh
if [ $? -eq 0 ]
then
sh b.sh
if [ $? -eq 0 ]
then
sh c.sh
fi
fi

you can add more lines to keep tack log information. Smilie
hth.
# 9  
Old 05-12-2005
have the succeeding scripts remove the marker file when they start if it exists ...
Code:
if [ ! -f /tmp/b.complete ]
then
    exit 0
else
    rm /tmp/b.complete
fi
...
...

# 10  
Old 05-12-2005
Just an enhancement to muthu's reply..

Scripts should be written in such a manner that the least number of commands are invoked.

It should probably look like this

m -f /tmp/a.complete
touch /tmp/b.complete

changes to

mv /tmp/a.complete /tmp/b.complete

Ofcourse, this would be very helpful if you have many a scripts.

Vino
# 11  
Old 05-12-2005
Quote:
Originally Posted by muthukumar
But default way is to $? to get the status of script execution. Return on every script with success and failure with exit 0 or exit 1 so that you can keep track with $? variable.

sh a.sh
if [ $? -eq 0 ]
then
sh b.sh
if [ $? -eq 0 ]
then
sh c.sh
fi
fi

you can add more lines to keep tack log information. Smilie
hth.
this is ok if the scripts are run sequentially by 1 script using 1 log file ... the code i offered is to fullfill the independent script run requirement ...
# 12  
Old 05-12-2005
Quote:
Originally Posted by vino
Scripts should be written in such a manner that the least number of commands are invoked.
...
mv /tmp/a.complete /tmp/b.complete
... you're absolutely right --- as long as they actually do what you want to accomplish ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

When were all scripts on the Solaris server last executed?

Hi All, I am new to this forum and I am hoping someone will be able to help me:) I have inherited a very old Solaris server that has a number of scripts around 500 in total. I need to migrate the scripts to Linux but I would like to know which ones are currently being executed rather... (10 Replies)
Discussion started by: josamy
10 Replies

2. Shell Programming and Scripting

Need to Replace the the Staus in last line

Hi Team, I have a increamental file like : 1033|20160120211644126508|1845828861|IN PROGRESS| 1033|20160120220756541604|1845828861|IN PROGRESS| 1033|20160120221051036757|1845828861|IN PROGRESS| 1033|20160120221208839263|1845828861|IN PROGRESS| 1033|20160120222550394230|1845828861|IN... (1 Reply)
Discussion started by: D_Sethi
1 Replies

3. 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

4. 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

5. UNIX for Advanced & Expert Users

Procedure to be executed from shell scripts

Hi, I am looking for a script wherein i will be able to execute below procedures one by one in line and next procedures starts only when the previous one completes and also after execution of each procedure i will be getting a automted mail as "PL/SQL PROCEDURE SUCCESSFULLY EXCETUTED". ... (1 Reply)
Discussion started by: sv0081493
1 Replies

6. AIX

Script not getting executed via cron but executes when executed manually.

Hi Script not getting executed via cron but executes successfully when executed manually. Please assist cbspsap01(appuser) /app/scripts > cat restart.sh #!/bin/ksh cd /app/bin date >>logfile.out echo "Restart has been started....." >>logfile.out date >>logfile.out initfnsw -y restart... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

7. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

8. Shell Programming and Scripting

Server Staus offline to online -Shell script

Hi, We put cron entry :whenever server is offline(checks every 5 minutes) it sends status to mailer group. The number of messages (offline)were growing in our mailbox.How to avoid not to send offline messages after the first one through shell script. Thanks in advance. Chowdary (2 Replies)
Discussion started by: chowdary_m
2 Replies

9. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

10. UNIX for Advanced & Expert Users

script to Monitor raid staus --Sun Volume manager

We use Sun Volume manager to mirror root disks and other local disks... Is there any script to monitor raid status across all machines send output thru email? Help is appreciated. Thanks. (1 Reply)
Discussion started by: sriny
1 Replies
Login or Register to Ask a Question