- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: shell script to find ips
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
Discussions
Discussions
Forums
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
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
тАО10-11-2005 10:15 AM
тАО10-11-2005 10:15 AM
I have server names list and want to find out ip address of the servers.
can someone suggest a shell script ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 10:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 10:48 AM
тАО10-11-2005 10:48 AM
Re: shell script to find ips
HOST=`hostname |cut -f1 -d"."`
DOM=`domainname`
[ -z "$DOM" ] && DOM="none"
/etc/lanscan |grep lan |awk '{print $5}'|while read LAN;do
IP=`/etc/ifconfig $LAN 2>&1 |grep inet |awk '{print $2}'`
MASK=`/etc/ifconfig $LAN 2>&1 |grep inet |awk '{print $4}'`
typeset -L4 M12
typeset -R4 M34
M12=$MASK
M34=$MASK
typeset -L2 M1
typeset -R2 M2
typeset -L2 M3
typeset -R2 M4
M1=`echo $M12|tr '[a-z]' '[A-Z]'`; m1=`echo ibase=16\;$M1|bc`
M2=`echo $M12|tr '[a-z]' '[A-Z]'`; m2=`echo ibase=16\;$M2|bc`
M3=`echo $M34|tr '[a-z]' '[A-Z]'`; m3=`echo ibase=16\;$M3|bc`
M4=`echo $M34|tr '[a-z]' '[A-Z]'`; m4=`echo ibase=16\;$M4|bc`
MASK="$m1.$m2.$m3.$m4"
[ "$IP" != "" ] && echo "$HOST $DOM $LAN $IP $MASK"
done
then, from a central server, I remsh to each server in the list and execute the script;
for server in node1 node 2 node3 ;do
remsh $server -n /usr/local/bin/get.ip.sh
done
This will generate results like the following format nodename nisdomain lan# IP netmask;
node1 nisdom lan2 170.208.6.203 255.255.255.192
node1 nisdom lan0 170.208.5.6 255.255.255.240
node2 nisdom lan0 170.208.5.4 255.255.255.240
node2 nisdom lan1 170.208.6.209 255.255.255.192
node3 nisdom lan0 10.12.2.150 255.255.255.128
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 10:52 AM
тАО10-11-2005 10:52 AM
Re: shell script to find ips
zpp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 12:41 PM
тАО10-11-2005 12:41 PM
Re: shell script to find ips
Alan, you can use perl (embedded in your shell) to convert your address:
a=ffffffc0 #...in your shell...
i=`perl -le 'print join(".",unpack("C4",pack("H8",$ARGV[0])))' $a`
echo ${i} #...returns the dotted notation
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 02:51 AM
тАО10-12-2005 02:51 AM
Re: shell script to find ips
Zero Points Please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 03:00 AM
тАО10-12-2005 03:00 AM
Re: shell script to find ips
I don't know if this is really better but it takes fewer lines and fewer calls to outside commands. Some people would consider that a plus I guess
#!/usr/bin/ksh
LAN=lan0
/etc/ifconfig ${LAN} |\
awk '/inet/ { printf "%s %s %s %s",\
substr($4,1,2),substr($4,3,2),substr($4,5,2),substr($4,7,2) }'|\
read a b c d
((A=16#$a));((B=16#$b));((C=16#$c));((D=16#$d))
echo $A.$B.$C.$D
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-12-2005 03:22 AM
тАО10-12-2005 03:22 AM
Re: shell script to find ips
ZPP