The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

Reply
 
LinkBack Thread Tools Display Modes
  #8 (permalink)  
Old 04-25-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
The outfile still very messy.

It looks like this:

10.72.169.110.72.169.210.72.169.310.72.169.410.72.169.510.72.169.610.72.169.710.72.169.810.72.169.91 0.72.169.1010.72.169.1110.72.169.1210.72.169.13datafeeds
Red Hat Enterprise Linux AS release 3 (Taroon)
10.72.169.1410.72.169.1510.72.169.16xenon.devo.ilx.com
Fedora Core release 5 (Bordeaux)
10.72.169.1710.72.169.1810.72.169.1910.72.169.2010.72.169.21lumines.devo.ilx.com
Fedora Core release 5 (Bordeaux)
10.72.169.2210.72.169.2310.72.169.24


However, someone of ip address maybe dead or no one using it. Does it make any different?
Reply With Quote
Forum Sponsor
  #9 (permalink)  
Old 04-25-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,084
I don't understand how you would get that output. Are you running the script exactly like I wrote it, just with an additional backquote after .../etc/redhat-release"?
Reply With Quote
  #10 (permalink)  
Old 04-25-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,084
You could also put the IP address inside the ssh command; then you don't get any output from hosts which don't respond.

Code:
for i in $(seq 1 254)
do
    ssh -o ConnectTimeout=3 root@10.72.169.$i "echo 10.72.169.$i `hostname` `cat /etc/redhat-release`"
done >result
Reply With Quote
  #11 (permalink)  
Old 04-25-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
I want the host ip to show up even though the ip isn't being used or dead, so i used the below script and now it only turns all numbers in single line...

for i in $(seq 1 254)
do
echo -n 10.72.169.$i >> result2
ssh -o ConnectTimeout=3 root@10.72.169.$i "hostname; cat /etc/redhat-release'" >> result2
done



RESULT:

10.72.169.110.72.169.210.72.169.310.72.169.410.72.169.510.72.169.610.72.169.710.72.169.810.72.169.91 0.72.169.1010.72.169.1110.72.169.1210.72.169.1310.72.169.1410.72.169.1510.72.169.1610.72.169.1710.72 .169.1810.72.169.1910.72.169.2010.72.169.2110.72.169.2210.72.169.2310.72.169.24
Reply With Quote
  #12 (permalink)  
Old 04-25-2008
in2nix4life's Avatar
Registered User
 

Join Date: Oct 2007
Location: East Coast
Posts: 43
Try variablizing the results:

Inside the loop:
host=`echo 10.72.169.$i`
server=`ssh -o ConnectTimeout=3 root@10.72.169.$i 'hostname'`
release=`ssh -o ConnectTimeout=3 root@10.72.169.$i 'cat /etc/redhat-release'`

then:
echo "$host $server $release" >> result
echo >> result

Hope this helps.
Reply With Quote
  #13 (permalink)  
Old 04-25-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
Thanks.

How how can I put a title in the output file?

For example:

IP Address HOSTNAME VERSION
10.72.169.1 abc fedora 5
10.72.169.2 ded fedora 5

Thanks again.
Reply With Quote
  #14 (permalink)  
Old 04-25-2008
in2nix4life's Avatar
Registered User
 

Join Date: Oct 2007
Location: East Coast
Posts: 43
You can use the '-e' switch with 'echo' and add tabs to line everything up:

echo -e "IP ADDRESS\t\tHOSTNAME\t\tRELEASE" >> result
echo -e "10.x.x.x\t\thostname\t\trelease" >> result

Hope this helps.
Reply With Quote
Google UNIX.COM
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0