Remsh on HP-UX hosts in for loop help

Soldato
Joined
1 Oct 2006
Posts
14,555
Hello,

I've got a bunch of ancient HP-UX boxes that I can't put SSH on, so I've got to use rsh. Long and the short of it, we've got a specific app that is connection sensitive and susceptible to network glitches - if the network drops for a split second then the user gets kicked out and a ghost session remains. So every now and then, we get a request to clear the sessions across 20 odd servers. When this happens for multiple users, it can be a very time consuming process.

So, started thinking about ways round this but ran into a bit of stick with the cronky HP-UX limitations. So, I've got a list of hosts in a text file which I'm calling in a script then running this command:

for host in `cat /tmp/hosts.txt`
do
echo $host
rsh $host ps -ef | grep 1.0.0.1 | grep -v | awk '{print $2}' | xargs kill -9
done

Now the "ps -ef | grep 1.0.0.1 | grep -v | awk '{print $2}' | xargs kill -9" bit works perfectly when executed on host, but when you rsh it the "xargs kill -9" portion of the command tries to run on the host you're rsh-ing from. Bummer.

I've been reading around, and it says to dump the command you want executed remotely into "" "" because of funkyness in HP-UX. Doesn't seem to work though as it then looks for a command called "xargs kill -9" - Failboat.

So, anyone have an idea of the syntax needed to make this work?

The dirty cheat way I used to night was to create a small shell script of the command needed and rcp it out to every host, then for loop the host list as above and run the script. :rolleyes:

Cheers in advance
:D
 
Customer boxes with stringent requirements and CM processes, they're pretty important monitoring boxes that need to be up 24/7/365. So they get a little jumpy when we mention any kind of work other than day-to-day.

I know, it would make more sense to have a preventative maintenance push on them - but they're that stubborn about it and we have tried in the past :(
 
I'm running it from a Solaris 9 box. Have tried various combinations of " " around different parts of the command but they all end in invalid strings being passed to kill (it quotes the syntax 20 odd times as it runs), or it tries to source the entire string as a standalone command which it fails to do.

Sometimes I wish they would just let us bring this boxes up to spec instead of working around these limitations, I mean they've trusted us enough for years to support and keep running - why not make changes?? :confused: meh!
 
Yep, tried -n too. The rcp script idea was the dirty work around, but it made me feel cheap and used lol.

I'll keep plugging away, cheers anyway!
 
Just saw you edit about my typo - yep, it was supposed to be "grep -v grep".

Alrighty, I'll give that a crack. Thanks for checking up on that one for me, much appreciated. :D
 
Back
Top Bottom