- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: while loop not working with remsh in a bourne ...
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
Forums
Discussions
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
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
06-29-2000 08:44 AM
06-29-2000 08:44 AM
#!/usr/bin/sh
remsh 123.45.678.999 ps -ef | grep -v tester | grep -v grep | awk '{print $2}' |
while read pid
do
remsh 123.45.678.999 kill -9 $pid
done
# end of script
Well, it only kills the first process found, i.e. it appears that after it does the first remote kill it exits the while loop although there are other processes listed for $pid.
The "local" version of the script works:
#!/usr/bin/sh
ps -ef | grep -v tester | grep -v grep | awk '{print $2}' |
while read pid
do
kill -9 $pid
done
Any ideas why the `remsh` is causing/allowing the script to loop only once?
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2000 09:38 AM
06-29-2000 09:38 AM
Re: while loop not working with remsh in a bourne shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2000 09:41 AM
06-29-2000 09:41 AM
Solutionremsh 123.45.678.999 kill -9 $pid
You need to use:
remsh 123.45.678.999 -n kill -9 $pid
As it now stands, the first time the line is run, it sucks up all the remaining pid lines and sends them to the remote kill process which ignores them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2000 09:54 AM
06-29-2000 09:54 AM
Re: while loop not working with remsh in a bourne shell script
the remsh -n simply redirects stdin from /dev/null.
You'll need to use the following format:
resmh
This will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2000 11:24 AM
06-29-2000 11:24 AM
Re: while loop not working with remsh in a bourne shell script
Adding the "-n" to the line worked.
A co-worker also suggested the idea of kicking off via remsh a script on the remote systems that would kill the processes. There are 29 that other systems.
Adding the "-c" didn't work. I received a "sh: -c: not found"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2000 01:25 PM
06-29-2000 01:25 PM
Re: while loop not working with remsh in a bourne shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2000 05:42 PM
06-29-2000 05:42 PM