Operating System - HP-UX
1834043 Members
2783 Online
110063 Solutions
New Discussion

Re: executing commands across systems

 
SOLVED
Go to solution
Ron Bromwell
Frequent Advisor

executing commands across systems

Hi all,
I have 5 C class machines that I am required to check different information on daily. I such check is the logical volume sizes. I wrote a script to work on one of the systems. It executes a bdf -i, checks for the existence of certain files, and checks for a process. All results are written to a log file. I can run this script in the mornings then more the log file to check the results.

What I want to be able to do is when the script runs, execute the needed commands on each system, but write the output to the logfile on the machine that contains the corn job for this script.

Any suggestions?
Thanks,
Ron
life's a journey, not a destination
7 REPLIES 7
Madhu Sudhan_1
Respected Contributor
Solution

Re: executing commands across systems

You need to setup /etc/hosts.equiv for hostequivalnce or .rhosts user equivalence. To an extent $HOME/.rhosts file has advantages of not having the same user in all the systems.

For example you can set up .rhosts file to have an entry as shown below, in the home directory of "bill" with 744 permissions.

+jim

So that "jim" from any machine can login to the system as "bill".

Once it is setup you can use the command in your script as

remsh saturn -l bill -n " bdf |...." >logfile.

Where saturn is the remote-hostname.
Here the logfie is created in the current machine where the cron/script is setup to run.

Hope this helps.
...Madhu



Think Positive
Rick Garland
Honored Contributor

Re: executing commands across systems

You can setup a trusted environment and have the script do a for loop to all the systems and remote execute the command. If you have SSH, you can setup the .shosts file to do the same thing. You can have a cron job on every system to execute a command that is local to that system and have the output mailed.

Different options for the environment you are in.
f. halili
Trusted Contributor

Re: executing commands across systems

What I understand is that you want to run different jobs locally and log them on a central server....

1. You may want run your files localy then create a local logfile.
2. rcp the your files to your central server
3. append all files to one big log file "# cat smallfile >> bigfile".


-fnhalili
derekh
Josef Nordtome
Advisor

Re: executing commands across systems

Hi Ron,

I just want to interject one comment. If you are using the direction symbols (>> or >) within your remote script, you won't get any output in the log that the remsh command is writing to. The only thing that remsh is able to direct to an output log is standard out. You can get around this by removing the direction symbols from your remote script or just add a cat statement to the end of your remote script. The information will then be piped back through the remsh command into the remsh log.

Hope this helps,
Josef
Life is something to do when you can't get to sleep.
Stefan Schulz
Honored Contributor

Re: executing commands across systems

If you have a mounted directory on all those servers, you could write the output to a file there.

So you dont have to copy the logfiles between the machines.
No Mouse found. System halted. Press Mousebutton to continue.
Dan Hetzel
Honored Contributor

Re: executing commands across systems

Hi Ron,

Eveything has been said about the .rhosts files configuration, so I imagine they are OK.

As long as your script is writing to stdout you may write a simple loop as the following:

for host in SYS1 SYS2 SYS3 SYS4 SYS5
do
remsh $host "/foo/bar/your_script -arguments" >> /localdir/logfile
done

The command to be executed is between quotes.
The redirection being outside the quotes will be applied locally. The double (>>) sign is needed otherwise your file will be overwritten each time.

You could redirect this way as well:

for host in SYS1 SYS2 SYS3 SYS4 SYS5
do
remsh $host "/foo/bar/your_script -arguments"
done > /localdir/logfile




Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
CHRIS_ANORUO
Honored Contributor

Re: executing commands across systems

Use sendmail to send log files to you mail box.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.