![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Feb 2004
Location: Right next to you....
Posts: 1,148
|
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
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Oct 2004
Location: Boston, MA
Posts: 1,723
|
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Join Date: Feb 2004
Location: Right next to you....
Posts: 1,148
|
Quote:
I could do a grep, but aint there any commands getting the IP address ? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Feb 2004
Location: Right next to you....
Posts: 1,148
|
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
backtick ?
get the ip from /etc/sysconfig/network-scripts/ifcfg-eth0 ?
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Jan 2005
Posts: 120
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |