HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: remsh break the while loop
Operating System - HP-UX
1834149
Members
2256
Online
110064
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
05-20-2007 02:42 AM
05-20-2007 02:42 AM
I working with posix shell and trying to run remsh
command in a while loop but the while loop break after
the first iteration of the loop .
Any idea why it happen ?
System is HPUX11.11
For example :
Assume I have 3 lines in /tmp/test
# cat /tmp/test
line1
line2
line3
#cat /tmp/test | while read line
>do
>remsh hostname1 date
>done
Thu May 17 14:03:43 IST 2007
if the other hand if I'm running the date command on local machine (not via remsh )
it runs the loop 3 times as expected .
# cat /tmp/test | while read line
> do
> date
> done
Sun May 20 23:25:54 METDST 2007
Sun May 20 23:25:54 METDST 2007
Sun May 20 23:25:54 METDST 2007
Thanks for any reply
Jose
command in a while loop but the while loop break after
the first iteration of the loop .
Any idea why it happen ?
System is HPUX11.11
For example :
Assume I have 3 lines in /tmp/test
# cat /tmp/test
line1
line2
line3
#cat /tmp/test | while read line
>do
>remsh hostname1 date
>done
Thu May 17 14:03:43 IST 2007
if the other hand if I'm running the date command on local machine (not via remsh )
it runs the loop 3 times as expected .
# cat /tmp/test | while read line
> do
> date
> done
Sun May 20 23:25:54 METDST 2007
Sun May 20 23:25:54 METDST 2007
Sun May 20 23:25:54 METDST 2007
Thanks for any reply
Jose
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2007 05:23 AM
05-20-2007 05:23 AM
Solution
Hi Jose:
You need to add the '-n' switch:
while read line
do
remsh hostname1 -n date
done < /tmp/test
Notice that I eliminated the extra 'cat' process and performed the read directly.
The 'remsh' manpages note that, "By default, remsh reads its standard input and sends it to the remote command because remsh has no way to determine whether the remote command requires input. The -n option redirects standard input to remsh from /dev/null."
Hence the behavior you see.
Regards!
...JRF...
You need to add the '-n' switch:
while read line
do
remsh hostname1 -n date
done < /tmp/test
Notice that I eliminated the extra 'cat' process and performed the read directly.
The 'remsh' manpages note that, "By default, remsh reads its standard input and sends it to the remote command because remsh has no way to determine whether the remote command requires input. The -n option redirects standard input to remsh from /dev/null."
Hence the behavior you see.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2007 09:55 AM
05-20-2007 09:55 AM
Re: remsh break the while loop
Your example doesn't show any use of $line, was that while-loop really needed? (Perhaps the name of each host?)
Note if the size of the file "test" is small, you can also use a for-loop:
for line in $(< /tmp/test ); do
remsh hostname1 -n date
done
Note if the size of the file "test" is small, you can also use a for-loop:
for line in $(< /tmp/test ); do
remsh hostname1 -n date
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2007 06:20 PM
05-20-2007 06:20 PM
Re: remsh break the while loop
Hello James,
Great.
I add the "-n" and it work fine .
Thanks,
Jose
Great.
I add the "-n" and it work fine .
Thanks,
Jose
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP