[Gambas-user] Obtain my IP with Gambas

Steven James Drinnan steven at ...2097...
Thu Sep 10 05:20:21 CEST 2009


You could try this

DIM mycmd AS String
DIM myIP AS String


mycmd = "ifconfig| grep -w 'inet addr' | grep -v '127.0.0.1' | cut -d:
-f2| awk '{print $1}'"

SHELL mycmd TO myip

PRINT myip

Have not confirmed what it returns but by the looks it returns the local
assigned ip. Not the wan side.


On Wed, 2009-09-09 at 19:12 +0200, Jean-Yves F. Barbier wrote:
> Benoît Minisini a écrit :
> >> On Wednesday 09 September 2009, Benoît Minisini wrote:
> >>>> mmmm it's OK, I think there must be something like User.IP :)
> >>>>
> >>>>  Regards
> >>>>
> >>>>
> >>>> --
> >>>> David
> >>> The IP address is not related to the user at all.
> >> How about System.IP?
> >>
> >>
> >> However David Villalobos did not tell which IP he wants.
> >> I do have a IP at the incomming connection of my building.
> >> For me known as WAN and a IP at the box, known to me as LAN.
> >>
> >> http://www.myipaddress.com for your WAN IP address :)
> >>
> >> Best regards,
> >>
> >> Ron_1st
> >>
> > 
> > IP address are attached to network interfaces, and I'm not sure that a network 
> > interface could not have several IP, and different types of IPs.
> 
> yep, that's right. 
> ie: you can easily attach multiple IP adresses to an Ethernet interface as aliases,
>     thus having one ethernet HW I/F that have 10 different IP addresses.
>  
> > Instead of adding thousands lines of code to the interpreter, I think the 
> > better is parsing the output of the ifconfig command.
>  
> that's right too, many programs/scripts return different strings, obliging
> the dev to consider each possible return
> 
> JY





More information about the User mailing list