![]() |
how to show the servers IP address in a shell script ?
hostname -i just give me the adress on the lo interface, i need the ip address from the eth0 interface :helpme
|
ifconfig -a
|
Quote:
I could do a grep, but aint there any commands getting the IP address ? |
I got it, ifconfig eth0 |grep 'inet addr' |awk '{print $2}'
My main problem now is that I need to get that saved in a variable, and i cant do VAR = ifconfig eth0 |grep 'inet addr' |awk '{print $2}' echo $VAR |
backtick ?
get the ip from /etc/sysconfig/network-scripts/ifcfg-eth0 ? |
This example works in a bash environment, just surround your command line in such a fashion:
[sf@steve]$ export TEST=`ifconfig rl0|grep netmask|awk '{print $2}'` -=[~]=- -=[Wed Jul 06]=- -=[17:18:06]=- [sf@steve]$ echo $TEST xxx.xxx.xxx.xxx (replaced for obvious reasons) You'll have to narrow the search down more if you have virtual IPs bound to the same interface, etc. S. |
All times are GMT -7. The time now is 03:30 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123