Running a check platform script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running a check platform script
# 1  
Old 01-18-2007
Running a check platform script

Hi,

I want to run a check platform & application script under ksh (Soaris boxes).
It runs some commands and it take some time.
I want to customize it like that:

- output is too big, hence I want some output of the commands to be redirect
ed in an output file (or maybe two or three) - not all just a part of them
& commands alternate by execution order
- I want to run it in bg only when I want to allow some
other jobs meanwhile - customize it by params.when it is launched?

Which is the easiest way to implement it?


Thx,
# 2  
Old 01-22-2007
Suppose your script is something like:

#!/usr/bin/ksh

test1
test2
if [ $somevar -eq 5 ]
then
test3
fi

if [ "`hostname`" == "bigserver" ]
then
test4
fi

test5
test6
test7

etc

You can group some part using "{" and "}" and redirect the output for all command withing a group to the same file.

so

#!/usr/bin/ksh
{
test1
test2
} > resultfile1

{
if [ $somevar -eq 5 ]
then
test3
fi

if [ "`hostname`" == "bigserver" ]
then
test4
fi
} > resultfile2

{
test5
test6
test7
} resultfile3


if you want errors included in those files just change e.g.
> resultfile1
into
> resultfile1 2>&1
# 3  
Old 02-03-2007
It works to group some part using "{" and "}" and redirect the output OK but in fact I want both - the output to be displayed and meanwhile to be redirected in some result file running the same command only once.
For some commands I want both for some other not.

Also I want that my script to analyse an output already generated previously - more specific:

After I run a "df -k" command I want that my output of "df -k" to be analysed later in the same script.
I'm interested only in those partitions that starts with "/dev/" or that have a specific name (excluding swap & similar) and if the percentage of the occupied space is greater than some critical value the script must display a NOK and in addition that line from "df -k" again as a warning - otherwise OK.

Does anyone know if this is possible?
# 4  
Old 02-03-2007
{
............
} | tee resultfile

to have output displayed as well as redirected to a file.

If you want to use the out of a command later on the script you either have to store the result in variables or send it to a file and read back this file later on.

The have the result of only specific filesystems is a matter of piping the output of df -k to grep with the right regular expression
# 5  
Old 02-03-2007
If the purpose of this script is to check the system and generate some kind of "alarms" in specific situations you better check out SNMP
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check if the script is already running?

I have one shell script in NAS shared location. Since NAS is mounted in many servers, script can be run from any of those servers. I want to make sure if the script is already running, it should not allow others to run it. I googled it and got some idea that i can touch one empty file in the... (8 Replies)
Discussion started by: thomasraj87
8 Replies

2. Shell Programming and Scripting

Check to see if script is already running

Happy New Year Is there a quick way to check to see if a script is already running. I want to put in a check in the script to exit, if already running. Currerntly i can only think of doing it the following way. # ps -ef | grep -i 3_HOUSEKEEPING_FFTVTL_TO_FFTDSSU_DUPLICATION.ksh |... (5 Replies)
Discussion started by: Junes
5 Replies

3. Linux

Check up the status of a Script (running or not)

Hello, i allready search on google und here in the local Forum, but can't found something. I need a query in php, that check whether a process (script) is running or not. Like this: php query: /usr/bin/Script01 >> if runnig, then: "Script01 is Online", if not "Script01 is Offline" I... (2 Replies)
Discussion started by: ProTechEx
2 Replies

4. UNIX for Dummies Questions & Answers

[Solved] How to Check if a script is running?

Hi All, I am new to Unix... Can you please let me know how we can check if a script is running or not on Solaris box? (4 Replies)
Discussion started by: Rahul466
4 Replies

5. Shell Programming and Scripting

Script to check running of process

Hi, Can anyone please tell me how to write a shell script to check whether a process if running or not.... if its still running then wait for sometime and if not then run the next query. Also, Under my one main script main.sh I have to run 2 scripts simutaneously which take some time to... (2 Replies)
Discussion started by: lovepujain
2 Replies

6. Shell Programming and Scripting

script to check if another script is running and if so, then sleep for sometime and check again

Hi, I am a unix newbie. I need to write a script to check wheteher another script is still running. If it is, then sleep for 30m and then check again if the script is running. If the script has stopped running then, I need to come out of the loop. I am using RHEL 5.2 (2 Replies)
Discussion started by: mathews
2 Replies

7. UNIX for Dummies Questions & Answers

check user id before running script

I am looking for the syntax to check which ID is executing script.sh. If the the ID, is not user1 then I want the script to exit and return to command prompt, if it is user1, then I want the script to continue. Any help would be greatly appreciate. Thank you. Chris (3 Replies)
Discussion started by: cpolikowsky
3 Replies

8. UNIX for Dummies Questions & Answers

running a Perl script on HPUX platform

Hi, I wish to execute a simple perl script to pass unix commands on a HPUX platform, retrieve the result and filter through the text to determine outcomes x,y and z. I am developing the code on my windows system. I initially wrote the code to issue UNIX commands line by line, however i soon... (1 Reply)
Discussion started by: mmetcalfe
1 Replies

9. Shell Programming and Scripting

Check if trigger Script is running

HI, I have a script which will be running all the time...it is like a trigger.. wakesup every 10 minutes(trigger.sh) executes, and I want to write another script which monitors this script every one hour and if it finds that trigger script is not running it should start it and exit...and here... (9 Replies)
Discussion started by: mgirinath
9 Replies

10. Shell Programming and Scripting

check that script is not running twice

using ps -ef | fgrep "ld_data" how do i write a script to check that it didn't already run Thanks (2 Replies)
Discussion started by: Link_02
2 Replies
Login or Register to Ask a Question