LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   IP Address (https://www.linuxquestions.org/questions/linux-newbie-8/ip-address-346495/)

paddyjoy 07-25-2005 06:24 AM

IP Address
 
Does anyone have any ideas how I can use script to obtain the IP address of the machine it is run on? I have looked through the bash environment variables but can't find anything that might help. Basically I have a dynamic IP with my ISP and I'm trying to write a script that will ftp my ip address in a txt to a different location every hour or so.

Paddy

Bruce Hill 07-25-2005 06:46 AM

To get your IP address from cli >
lynx -dump http://whatismyip.com | awk '/Your/ {print $4}'

Razze 07-25-2005 06:56 AM

You can also take a look at www.dyndns.org. There you can link a dynamic ip to a static computer name.

paddyjoy 07-25-2005 07:05 AM

Thanks for the help. I have edited your command slightly so that I can get the ip address from the output of the ifconfig command like this.

Code:

ifconfig eth1 | awk '/Bcast/ {print $3}' | tail -c 15
Paddy

Bruce Hill 07-25-2005 07:20 AM

That wouldn't do me any good.
Code:

mingdao@james:~$ /sbin/ifconfig eth0 | awk '/Bcast/ {print $3}' | tail -c 15
:192.168.1.255


paddyjoy 07-25-2005 07:54 AM

Yeah I suppose if you are behind a router it wouldn't be much use but in my case my computer is plugged directly into my modem so works for me.

Paddy


All times are GMT -5. The time now is 06:45 PM.