- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scripting question
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
09-11-2006 08:34 PM
09-11-2006 08:34 PM
My scrpit is the following:
while read host;
do
ssh -n ${host}
done < hostlist.txt
hostlist.txt contains:
hostname2 12 Sep 12:00
hostname3 12 Sep 13:00
How to make shell get only hostname from string, so would be able to ssh hostname1 then hostname2 etc.?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 09:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 09:08 PM
09-11-2006 09:08 PM
Re: scripting question
match the number of parameters to the number of fields
while read host a b c
which means hostname is read into host, the rest into a b and c, whcih can be ignored.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 09:12 PM
09-11-2006 09:12 PM
Re: scripting question
would print the hostname. (you could use awk too if you like)
for host in $(cat hostlist.txt | perl -ane '{print "F[0] "}'
do
ssh -n $host
done
or as you have done it as a read..
while read host;
do
ssh -n ${host}
done < $(cat hostlist.txt | perl -ane '{print "F[0] "}'
Regards
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 09:18 PM
09-11-2006 09:18 PM
Re: scripting question
try:
while read host restofline;
do
ssh -n ${host}
done < hostlist.txt
This will assign the first "word" to $host and the rest of the line to $restofline.
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2006 09:56 PM
09-11-2006 09:56 PM
Re: scripting question
All suggestions are quite good!