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
07-17-2003 01:07 PM
07-17-2003 01:07 PM
script
while read line
do
remsh $line model
done < hostfile
I want to read the hostname from hostfile and run the command for each host. It runs for first host and comes out of loop.
If I replace command "remsh $line model" with "echo $line" it displays all the hosts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 01:16 PM
07-17-2003 01:16 PM
Re: script
The problems you receive are related to the way remsh works. Try the following:-
while read line
do
remsh $line -n "model"
done < hostfile
Rgds,
Paul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 01:18 PM
07-17-2003 01:18 PM
Re: script
do
remsh $x model
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 01:24 PM
07-17-2003 01:24 PM
Re: script
Try this in csh:
foreach host (`cat hostfile`)
remsh $host model
end
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 11:03 PM
07-17-2003 11:03 PM
Re: script
apart from others hint,
how is the file "hostfile" structure ?
Is it like
node1
node2
node2
or different ?
I think that your situation was
node1 node2 node3
this way the command read get only the first node, node1.
If you want to do the loop for all of them,
or you use a $( cat hostfile ) or change its structure.
the read command works in a slight different manner than you think.
read var1 var2 var3
reads a line of input, and put first field in var1, second in var2 and ALL other input in var3.
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 11:14 PM
07-17-2003 11:14 PM
Re: script
HOSTLST=/tmp/hosts.lst
for host in $(cat $HOSTLST)
do
< run your commands here >
done
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2003 11:40 PM
07-17-2003 11:40 PM
Re: script
"... read var1 var2 var3
reads a line of input, and put first field in var1, second in var2 and ALL other input in var3....
that sounds that read can only process three variables. But this is not correct. Here what the manpage from read says to this:
read reads a single line from standard input. The line is split into fields as when processed by the shell (refer to shells in SEE ALSO); the first field is assigned to the first variable var, the second field to the second variable var, and so forth. If there are more fields than there are specified var operands, the remaining fields and their intervening separators are assigned to the last var. If there are more vars than fields, the remaining vars are set to empty strings.
Hey Massimo, I think you mean it like this :-}}
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 12:00 AM
07-18-2003 12:00 AM
Re: script
You can have comments and blanks in /etc/hosts
grep -v "#" /etc/hosts|strings|while read ip name
do
remsh $name model
done
Or if your file contains only hosts then
cat hostfile|while read line
do
remsh $line model
done
Your solution reads all in 1 line with <
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2003 12:03 AM
07-18-2003 12:03 AM
Re: script
Roland, you are perfectly right, i wanted to give an example, but forgot to mention it :)
Thanks for the remark.
Massimo