The situation is a data center with around 800 servers.
Each server has installed one of these unix-like OS: rhel, sunos, aix, hp-ux.
And we have to make scripts general enough to being able to be executed over all these servers.
Furthermore, sometimes the scripts will be executed as a normal user and sometimes they will be executed as root.
The problem is:
sometimes the path for the binaries used into the script are in one place, and sometimes they are in another place. So the variety of different places the binaries used into the script are placed is big.
So, to make the scripts "bomb-proof" we're using this strategy:
First line of each script is containing a:
In general, we're assigning to the PATH variable the content it had ($PATH) plus the content of all the PATH variables of the user root of each type of OS plus some "usually known places for rare binaries temporary used like inqraid in /var/tmp or in /home/ouruser" on some servers.
After doing this PATH assignment, we're checking for each command used in the script if it is in the path, checking it with the
command. If one of the binaries used in the script is not in our "MEGAPATH" we exit with a message saying the binary X needed to executed the script is not in the PATH.
My question is:
Is this the better way to ensure the different binaries we should use in a script are in the PATH before continuing with the execution of the script? I'm open to different suggestions. Thank you!
Assuming the paths are based on the system and all systems have the same shell, you could find out the system at the start, then set the PATH accordingly.
Assuming ksh93 on Sun (code is untested but you get the idea):
Pros: Generic.
If paths change, you only have to set them in one place, at the top of the script.
Caveats: if the command you need to run exists in multiple locations, make sure you are running the right one. This would be controlled by the order in which you build the PATH.
I got a little carried away, but it was an interesting lunchtime distraction. :-)
I have to kill the process "test" for a maintenance I do but want the script to check when it comes back up.
I can get what I want when I run this while loop:
while true;do ps -ef | grep test | grep -v grep | sed -e 's/^*//';sleep 60;done
but I want the script to do it for me and as soon as... (6 Replies)
Hi all!
Im working on a simple script in KSH (just started) to check if a process its up or down, but im kind of lost with the following error.
Script:
#!/usr/bin/ksh
psup=$(ps -ef | grep sftp | egrep -v grep | wc -l)
if ($psup > 0);
then
echo "Process SFTP running"
else
... (6 Replies)
Hello,
I would like to create a shell script which would check whether the hosts have SAN dual path or not. If yes, then I should get a success message, else should get a list of hosts on which SAN dual path is not working.
Thanks.. (4 Replies)
Please help, I want script to check filename, size and date in specify path.
I want output as:
DATE: YYYYMMDD HH:MM
------------------------------------------------
fileA,filesize,yyyy mm dd HH:MM
fileA,filesize,yyyy mm dd HH:MM
fileA,filesize,yyyy mm dd HH:MM
fileA,filesize,yyyy mm dd... (1 Reply)
Hi All,
I am very new to scripting and wanted to write a script for comparison of folder including binary files like ear's and jars. Following is the job for which I need it:
1. Compare two folders recursively
2. Compare the binaries like ear's but exclude files like MANIFEST files
3.... (1 Reply)
I am trying to code a ksh script that will check to see if all 26 incoming ftp files have been received before proceeding to the next function, which is to rename each file.
Here is the pseudo-code of what I am trying to do:
<<STEP_1>>
IF all ALS files have been transmitted then... (2 Replies)
UNIX Shell Script
I'm in /home/suneel dirctory
in that directory need to check for a path for example com/src/resources
If Path exists need to copy the files from one directory
If path not exist need to create the folders and copy the files
UNIX shell script help required (3 Replies)
Hi
I have a path link
/test/df/link1/actual/file1
here link1 is actually a softlink link1= a/b
i need to print the ACTUAL FULL path instead of a linked path
is there any direct command to print the actual path of any linked path
eg
showPhyscialPath /test/df/link1/actual/file1 and it... (4 Replies)
Hello all,
Here's the scenario:
I've got a script, let's call it script1. This script invokes another script, which we'll call set_env, via the dot "." command, like so:
File:
#!/bin/ksh
#
region_id=DEV
. set_env ${region_id}
and so on. Script set_env sets up an... (2 Replies)
Hey everyone,
I'd like to determine the absolute path of where a script resides from within the same script. For example, I have a script - /tmp/myscript. Regardless of how that script is call - '/tmp/myscript', 'cd /tmp;./myscript', '. /tmp/myscript' - I'd like to be able to determine - from... (5 Replies)