- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- remsh in a loop
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 03:27 AM
04-04-2005 03:27 AM
Long time :-). I would like to think myself as a reasonably skilled scripter but this one baffled me. I just could not figure out what am I missing here.
I have this file serverlist that lists all the servers with some comments in between
# grep -v "^#" serverlist | wc -l
109
#
All I am trying to do is to execute a simple command via remsh to all of the machines from a node that has .rhosts entries
# grep -v "^#" serverlist | awk '{print $1}' | xargs -n1 | while read SERVERNAME
> do
> remsh $SERVERNAME "echo Hey"
> done
Hey
Hey
#
Why on the god's green earth the loop will exit just after two iteration? Even if there is something wrong, I should get an error message from remsh
# grep -v "^#" serverlist | awk '{print $1}' | xargs -n1 | while read SERVERNAME
> do
> echo $SERVERNAME
> done | wc -l
109
#
Am I missing something very obvious?
- Sundar.
Solved! Go to Solution.
- Tags:
- remsh
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 03:45 AM
04-04-2005 03:45 AM
Re: remsh in a loop
xargs -i echo remsh {} "some command"
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 03:54 AM
04-04-2005 03:54 AM
Re: remsh in a loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 05:50 AM
04-04-2005 05:50 AM
Re: remsh in a loop
check "which grep" you are using.
check "which awk" you are using.
check "which xargs" you are using.
check "chich remsh" you are using.
Also, try replacing the remsh $SERVERNAME line with this:
host ${SERVERNAME}
just to make sure you have "good" server names.
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 06:08 AM
04-04-2005 06:08 AM
Re: remsh in a loop
for SERVER in `grep -v "^#" serverlist | awk '{print $1}' | xargs -n1 `
do
echo "$SERVER"
remsh $SERVER "echo hey"
done
Can you post your serverlist file?
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 06:18 AM
04-04-2005 06:18 AM
Re: remsh in a loop
Harry - if there are funky names, how do you think xargs -i remsh {} is working ?
grep -v "^#" serverlist | awk '{print $1}' | xargs -i remsh {} date
this work. Doesnt it confirm the grep, awk ,xargs and the serverlist are just fine ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 06:23 AM
04-04-2005 06:23 AM
Re: remsh in a loop
remsh $SERVERNAME "echo Hey"
to
remsh $SERVERNAME /usr/bin/echo Hey
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 08:01 AM
04-04-2005 08:01 AM
Re: remsh in a loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 08:18 AM
04-04-2005 08:18 AM
Re: remsh in a loop
Just a wild guess :-)
Does your serverlist file have a comment which
starts in the middle of a line? In other words, do
you have a '#' char at some place other than
first column?
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 08:46 AM
04-04-2005 08:46 AM
Re: remsh in a loop
Can you post your "input" file "serverlist" ??
thanks,
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 08:48 AM
04-04-2005 08:48 AM
Re: remsh in a loop
type grep awk xargs remsh
(type is an automatic alias wo whence -v)
AS far as the 3rd item failure, echo the value of $SERVERNAME just before issuing the remsh command and also check the validity of the server name with getip:
grep -v "^#" serverlist | awk '{print $1}' | xargs -n1 | while read SERVERNAME
do
MYIP=$(getip $SERVERNAME)
echo "$SERVERNAME: IP=$MYIP"
remsh $SERVERNAME "echo Hey"
done
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 09:02 AM
04-04-2005 09:02 AM
Re: remsh in a loop
IF
for SERVER in $(grep -v "^#" serverlist | awk '{print $1}')
do
remsh $SERVER echo Hello
done
AND
grep -v "^#" serverlist | awk '{print $1}' | xargs -i remsh {} echo Hello
WORKS, WHY
grep -v "^#" serverlist | awk '{print $1}' | xargs -n1 | while read SERVER
do
remsh $SERVER echo Hello
done
IS NOT WORKING ?
I am using the same
1) grep
2) awk
3) xargs
4) serverlist file
5) same remsh command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2005 05:26 PM
04-04-2005 05:26 PM
SolutionFrom remsh(1)
If a command and the option -n are specified, then standard input is redirected to remsh by /dev/null. If -n is not specified (the default case), remsh reads its standard input and sends the input to the remote command. This is because remsh has no way to determine whether the remote command requires input. This option is useful when running a shell script containing a remsh command, since otherwise remsh may use input not intended for it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 01:43 AM
04-05-2005 01:43 AM
Re: remsh in a loop
Put in say 10 servers - then test your script...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 01:57 AM
04-05-2005 01:57 AM
Re: remsh in a loop
grep -v "^#" serverlist | awk '{print $1}' | vis
And
grep -v "^#" serverlist | awk '{print $1}'|vis|xargs -n1
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2005 07:48 AM
04-05-2005 07:48 AM
Re: remsh in a loop
ksh, csh, sh variances ?