Click to See Complete Forum and Search --> : Command to get IP address?


Bradmont
04-05-2001, 09:57 PM
Can anybody tell me the command to check my IP address? I can do it with some apps, but I want to write a script to e-mail one of my web-based accounts whenever it changes... (the stupid thing changed today, after a month and a half of being static, preventing me from ftping home and getting my homework :mad :). But anyway, an app/command that echos just my IP would be great (tho if additional nfo was provided, I guess I could sift that out).

Thanks.

crokett
04-05-2001, 10:18 PM
ifconfig displays ip information

ifconfig > ipinfo redirects the output to a file called ipinfo

Bradmont
04-05-2001, 10:22 PM
Thank you muchly.

bdg1983
04-06-2001, 06:13 AM
I've got a few scripts that will do the same. Here's one of them.

#!/bin/bash
# getIP.sh
# the following is one line:
IPADDR=$(/sbin/ifconfig eth0|grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}')
printf "IP address: $IPADDR\n"