Operating System - HP-UX
1753378 Members
5245 Online
108792 Solutions
New Discussion юеВ

Re: telnet session script

 
wish_1
Frequent Advisor

telnet session script

Hai All,

we are having 9 server for these server i have to moniter and note the cpu usage, mem usage, no of user.... for this i login to each server and note...

can any one of you tell the script to open 9 telnet session with one script..

thanks in adv
wish
5 REPLIES 5
Silver_1
Regular Advisor

Re: telnet session script

Hi,

you can achieve this making a trust between servers, and then running a script.

Also if you have Secure Shell installed, you can very easily establish a trust between the servers and then run a script.

For EG:

for HOST in hp1 hp2 hp3
do
echo #HOST
ssh $HOST w;..;..
done
Silver_1
Regular Advisor

Re: telnet session script

minor correction

for HOST in hp1 hp2 hp3
do
echo $HOST
ssh $HOST w;..;..
done
wish_1
Frequent Advisor

Re: telnet session script

Dear Silver,

First of all thanks you.

If my 9 server names are one, two,....nine
and what to run script from one of the pcs in the same subnet - then what would be the script i want to know that step by step pl reply....

thanks in adv
regds
wish
Rory R Hammond
Trusted Contributor

Re: telnet session script

I have used 2 methods to accomplish what you want uucp\uux is one Kermit is another. Kermit does come with hpux, Shown is a contribed example. I did not test it but it is from working code. you would need to flush out error checking and the command you want to really do
Rory


#!/bin/sh
#
#

dojob()
{
TOHOST=`echo $1`
WAIT_THIS_LONG="${2}" #added to allow for wait of long commands
WAIT_THIS_LONG=${WAIT_THIS_LONG:-10} #default if not set
echo "
set network TCP/IP
#set host 10.254.7.34
set host ${TOHOST}
input 10 login:
if failure exit 1 No login prompt
output USERID\13
input 10 word:
if failure exit 1 No password prompt
output PASSWD\13
input 10 $
ls -ld \13
input ${WAIT_THIS_LONG} $
output exit\13
output quit
"
}


for HOST in 10.254.0.1 10.254.0.2 10.254.0.3 10.254.0.4
do
trap "" 1 2 3
#passwords and USERID can be set as variables past to kermit
#like host and timeout
dojob ${HOST} 4600 |/usr/bin/kermit
trap 1 2 3
done

There are a 100 ways to do things and 97 of them are right
Arturo Galbiati
Esteemed Contributor

Re: telnet session script

Hi Wish,
my sugegstoin id to prepare a script which collects all the required data and run it on all the server by remsh:

for server in one two three four
do
remsh $server -l $user -n "script"
done

to do this you have to add an entry in the target .rhost

or in alternative you can use rexec instead of rmsh. In this case you have to create a file .netrc on the source server with the logon info for the target server.
For furhet info man rexec, remsh can help.


HTH,
Art