1845904 Members
4427 Online
110250 Solutions
New Discussion

remote shell help

 
Hanry Zhou
Super Advisor

remote shell help

We have about hundreds hp and sun mixed servers, and we want to run a command, ex, top command on each one of systems, and get the result back.

Can anybody please help me out on ksh scripting?

Thanks,
none
3 REPLIES 3
Leif Halvarsson_2
Honored Contributor

Re: remote shell help

Hi,
There is no top command as default in Solaris (but it exist as freeware).

It is not hard to write a script which read a list of hosts (for example from a file, and do a remsh (or rsh if Solaris) to the hosts, but yith hundreds of hosts I don't think it is very useful.

while read host os
do
if [ os == Solaris ]
then
rsh $host
else
remsh $host
fi
done
Leif Halvarsson_2
Honored Contributor

Re: remote shell help

Sorry,
There was an error. It should be
if [ os = Solaris ]

And the host where the script is run must be in the /etc/hosts.equiv or .rhosts file on all remote hosts.



Bill Douglass
Esteemed Contributor

Re: remote shell help

First, I strongly recommend setting up ssh for this, along with public/private key authentication. Then your can easily execute commands remotely, as well as copy files to hosts. See the ssh, ssh-keygen, ssh-agent and ssh-add man pages for this.

Solaris 9 has ssh included; Solaris 8 has it available at www.sunfreeware.com (openssh, which requires openssl, zlib and libgcc or gcc-3.2.2).

HP-UX has ssh available at
http://www.software.hp.com/cgi-bin/swdepot_parser.cgi/cgi/displayProductInfo.pl?productNumber=T1471AA

or you can get the depot and source at

http://hpux.cs.utah.edu


For the script, create a file with the host names. The, in your script, do:

for i in `cat /path/to/hostnames/file`
do
echo $I # print current host
ssh $i $*
done


call it as

hostcmd