Operating System - HP-UX
1834007 Members
1843 Online
110063 Solutions
New Discussion

Need Help for remsh script

 
SOLVED
Go to solution
Peter Lachnitt
Advisor

Need Help for remsh script

Hello all,
I am try to using a script to change lines in the /etc/passwd and /etc/group on dif. servers.
It works on the local server but not on the remote server.

remsh $i \
sed '/kal/s/$/,maierchr,knoerpte/' /etc/group > /etc/tmp_group
/usr/bin/mv /etc/tmp_group /etc/group

sed '/maierchr/s/201/84/g' /etc/passwd > /etc/tmp_passwd
/usr/bin/mv /etc/tmp_passwd /etc/passwd

sed '/knoerpte/s/201/84/g' /etc/passwd > /etc/tmp_passwd
/usr/bin/mv /etc/tmp_passwd /etc/passwd

fi
done

exit 0

Thanks

Peter Gaube

Peter Lachnitt
3 REPLIES 3
Robin Wakefield
Honored Contributor

Re: Need Help for remsh script

Hi Peter,

You appear to have a quote problem - as it stands, everything after the 1st sed is running locally, so:

remove the double-quote at the end of the first sed and from both ends of the following line. Insert a double-quote at the end of the last mv.

remsh $i \
"sed '/kal/s/$/,maierchr,knoerpte/' /etc/group > /etc/tmp_group
/usr/bin/mv /etc/tmp_group /etc/group
sed '/maierchr/s/201/84/g' /etc/passwd > /etc/tmp_passwd
/usr/bin/mv /etc/tmp_passwd /etc/passwd
sed '/knoerpte/s/201/84/g' /etc/passwd > /etc/tmp_passwd
/usr/bin/mv /etc/tmp_passwd /etc/passwd"

Rgds, Robin.
Herve BRANGIER
Respected Contributor

Re: Need Help for remsh script

Hi

Think you have to put your multiple commands
in " ", for example :

remsh $i "cd / ; ls "

And use ; to separate your commands.

When you call remsh for more than one command
you must consider you are in command line and
want your commands string together.

HTH

Herv?

Herve BRANGIER
Respected Contributor
Solution

Re: Need Help for remsh script

Hi again

I'm also working on scripts using remsh...
I saw that when you ping an unreachable host
return value for ping is 0 like for host you
can ping...

Are you sure about your test on ping's return
value ?

The only way I found was :
if [ -n `ping $i 100 -n 1 | grep "0 packets received"` ]

You can also test with a remsh (remsh $i /bin/ls >/dev/null) it return 0 only if command
was executed...

HTH

Herv?