Sponsored Content
Top Forums Shell Programming and Scripting Shell script with mutiple steps/commands, on UNIX servers Post 302839349 by Don Cragun on Thursday 1st of August 2013 06:40:49 AM
Old 08-01-2013
This is untested, but should do what I think you're asking for:
Code:
#!/bin/ksh

SERVER=$(hostname)
MAILTO=abc@company.com
DATE=$(date)
ps -ef | grep '[j]ava' | mailx -s "JVM status before start" $MAILTO


if ! /was/abc/bin/startManager.sh > /tmp/start.log
then    mailx -s "ALERT: dmgr started $SERVER at $DATE" $MAILTO < /tmp/start.log
        exit 1
fi
sleep 30

if ! /was/abc/bin/startnode.sh > /tmp/start.log
then    mailx -s "ALERT: node started $SERVER at $DATE" $MAILTO < /tmp/start.log
        exit 2
fi
sleep 30

if ! /was/abc/bin/startServer.sh > /tmp/start.log
then    mailx -s "ALERT: server started $SERVER at $DATE" $MAILTO < /tmp/start.log
        exit 3
fi
ps -ef | grep "[j]ava" | mailx -s " node1 got started" $MAILTO

######### node 2 #############
date >> /tmp/b4strtnd2.log

ssh noide2 exec /tmp/script/mystrtscpt.sh

exit

Did you really intend ssh noide2, or should it have been ssh node2?

Note that this will only work correctly if /was/abc/bin/startManager.sh, /was/abc/bin/startnode.sh, and /was/abc/bin/startServer.sh all return exit status 0 if they complete successfully and return a non-zero exit status if they fail. Assuming that is true this script will return exit status 1, 2, or 3, respectively if one of those scripts fails; otherwise it will return with the exit status from /tmp/script/mystrtscpt.sh on noide2.

Last edited by Don Cragun; 08-01-2013 at 07:42 AM.. Reason: Add missing <newline>
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies

2. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

3. Shell Programming and Scripting

Unix commands failing inside the shell script

When my script deals with large input files like 22Gb or 18 GB the basic commands like sort or join fails when run from inside the shell scripts. Can there be any specific reason for this? For e.g. sort -u -t "," -k1,1 a.csv > a.csv.uniq" sort -u -t "," -k1,1 b.csv > b.csv.uniq" The... (3 Replies)
Discussion started by: esha
3 Replies

4. Shell Programming and Scripting

How to incorporate mutiple commands in Autosys commandline on UNIX

Hi, I am having a problem running multiple commands in a autosys command line. For example I would like to run a perl script first and then add sleep command after that in the same autosys job like below insert_job: xxxxxxxxx command: `perlscript.pl ; sleep 180` Perlscript.pl... (0 Replies)
Discussion started by: waavman
0 Replies

5. Shell Programming and Scripting

to create a phone book using shell script and unix commands

can you help me to create a phone book with add, delete, modify with first name, last name, middle name, phone no(multiple ph no), address, email address, notes or comments to store about the contact and groups that hold for the contact.. i am new to this linux environment. please guide me. ... (1 Reply)
Discussion started by: monster11209
1 Replies

6. Shell Programming and Scripting

Need help embedding Unix commands in a shell script

Hi Folks, I have a text file which may or may not have any data. I would like to email the file, via a Korn shell script, if the file is not empty. I am fiddling around with the wc -l command, but no luck so far. The pseudo code is as follows count=`wc -l test.txt` if cat test.txt... (4 Replies)
Discussion started by: rogers42
4 Replies

7. UNIX for Dummies Questions & Answers

awk script combining mutiple commands

Hi, I am pretty new to the unix community and have encountered a problem that I am trying to solve. I have 2 files one of which is called passwd file that looks like the following Sample Output daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh ... (1 Reply)
Discussion started by: raven905
1 Replies

8. Shell Programming and Scripting

Running set of commands in remote servers in shell script

Hi Wishing to all. I am very new joined in an organization as a unix system administrator. I need a help in preparing a script for a report. i have a file contains all of the linux/ubuntu servers line by line around 140 servers. vi servers.txt nh01 nh02 nh03 bh01 bh04 - - :wq (3 Replies)
Discussion started by: kumaraswamy
3 Replies

9. Shell Programming and Scripting

Shell script to set user password to never expire in UNIX servers

Hi, I have a requirement where in i need to write a shell script to set users password to never expire. I know the command which is used to perform the same .. which is chage command. But, could not figure out how to do the same in shell script. Could you please help me with the shell... (3 Replies)
Discussion started by: suren424
3 Replies

10. UNIX for Beginners Questions & Answers

How to ignore mutiple strings when using shell script?

Hi All, I am trying to use below syntax to find ignore multiple locations while searching for a file. find / -name "$serviceitem" ! -size 0 2>&1 |egrep -v "tmp|docker|WinSxS|Permission|HISTORY|alternatives|bearer11ssl|manifest" I tried to assign all the ignore strings to one variable... (2 Replies)
Discussion started by: sravani25
2 Replies
SCRIPT-EMAIL(8) 					  System Administration Commands					   SCRIPT-EMAIL(8)

NAME
script-email - Amanda script to send email notifications DESCRIPTION
script-email is an Amanda script implementing the Script API. It should not be run by users directly. It sends a notification email to the addresses specified in the MAILTO property. PROPERTIES
This section lists the properties that control script-email's functionality. See amanda-scripts(7) for information on the Script API, script configuration. MAILTO List of email addresses that will receive an email on command execution. It is a multi-valued property: property "MAILTO" "amanda@domain.com" "sysadmin@domain.com" "amandauser@domain.com" EXAMPLE
In this example, script-email is scheduled to be run before the DLE, on the server. The unqualified email address amanda will be passed to the email system unchanged. The script is then attached to a dumptype, which can then be specified for any DLEs which require notification. define script-tool pre-email { comment "email me before this DLE is backed up" plugin "script-email" execute-on pre-dle-backup execute-where server property "mailto" "amanda" } define dumptype user-tar-email { user-tar script "pre-email" } SEE ALSO
amanda(8), amanda.conf(5), amanda-client.conf(5), amanda-scripts(7) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHORS
Jean-Louis Martineau <martineau@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Dustin J. Mitchell <dustin@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.1 02/21/2012 SCRIPT-EMAIL(8)
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy