Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Forums
Blogs
Articles
Groups
Galleries
Member List
Calendar
Home
Forum
Simply Business
Fucking Around & Business Discussion
how to show the servers IP address in a shell script ?
how to show the servers IP address in a shell script ?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
etech
Confirmed User
Join Date:
Feb 2004
Posts:
1148
Share
Post
#1
how to show the servers IP address in a shell script ?
07-06-2005, 11:11 AM
hostname -i just give me the adress on the lo interface, i need the ip address from the eth0 interface
SinSational
Confirmed User
Join Date:
Oct 2004
Posts:
1723
Share
Post
#2
07-06-2005, 11:14 AM
ifconfig -a
ICQ# 273099174 - monthly specials -
2 Month Free Credit on All Plans
- 100% Referrals - chris@ for details
Virtual from $14.95/month, Dedicated from $149.95/month
Dual-Core Xeon > 1000GB @ $149.95 | 1500GB @ $169.95 | 10Mbps @ $269.95
Comment
Post
Cancel
etech
Confirmed User
Join Date:
Feb 2004
Posts:
1148
Share
Post
#3
07-06-2005, 11:18 AM
Originally posted by
SinSational
ifconfig -a
Yes, but that show all the info, i just need the IP.
I could do a grep, but aint there any commands getting the IP address ?
Comment
Post
Cancel
etech
Confirmed User
Join Date:
Feb 2004
Posts:
1148
Share
Post
#4
07-06-2005, 11:28 AM
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
Comment
Post
Cancel
Brujah
Beer Money Baron
Join Date:
Jan 2001
Posts:
22157
Share
Post
#5
07-06-2005, 11:53 AM
backtick ?
get the ip from /etc/sysconfig/network-scripts/ifcfg-eth0 ?
Free Premium Domain Lists and Tools at
Clickmojo.com
For Sale:
Obscenity.com
Comment
Post
Cancel
SteveF
Confirmed User
Join Date:
Jan 2005
Posts:
120
Share
Post
#6
07-06-2005, 01:21 PM
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.
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
😀
😂
🥰
😘
🤢
😎
😞
😡
👍
👎
☕
Comment