Re: How do i find dynamic IP assigned?
On 2005-06-22, Andrea Ganduglia wrote:
> On 6/21/05, Valeriu Cerchez <vcerchez@yahoo.com> wrote:
>> I'm trying to find out a(/n easy) way to determine
>> what is my dynamic IP assigned by my ISP (not my
>> internal DHCP). I wish to make a script to determine
>> that by request.
>>
>> I would greatly appreciate any suggestion.
>> Thanks, Val.
>
> Surely possible way is:
> ifconfig | grep -1 ppp0 | tail -1 | sed 's/.*r://' | sed 's/ .*$//'
>
> Replace ppp0 with your active interface.
There's no need for grep, tail or sed:
temp=$(ifconfig ppp0) ## Replace ppp0 with your active interface.
temp=${temp#*addr:}
ip=${temp%% *}
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
==================================================================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
Reply to: