Getting OS information

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting OS information

Marco D'Ambros
Hi,

how can I get the ip address of the computer from vw? And the operating
system (something like the unix command "uname")?

Thanks and cheers
Marco D'Ambros

Reply | Threaded
Open this post in threaded view
|

Re: Getting OS information

Runar Jordahl
Reply | Threaded
Open this post in threaded view
|

Re: Getting OS information

Emiliano Pérez-3
Hi Marco, some time ago i had the same problem and solved using OS commands for the ip address, in windows it would look something like this:

(ExternalProcess defaultClass cshOne: 'ipconfig /all') readStream.

That should return all the info, with a little parsing you can get the MAC, ip addresses, etc....
For ubuntu i remember using something like this:

(ExternalProcess defaultClass shOne: ifconfig | grep inet addr) readStream.

And for the SO identification "Screen default platformName" should work fine, it returns a string (MS-Windows, X11, etc...).

Hope it helps, Emiliano.
Reply | Threaded
Open this post in threaded view
|

Re: Getting OS information

fede-7
I didn't try this method but in my linux box only root can do ifconfig.
Moreover, "ifconfig | grep inet\ addr" will list all the interfaces  
including the loopback which has a different format than the other ones.

It has to be a better way to get this information...

Federico

Quoting Emiliano Pérez <[hidden email]>:

> Hi Marco, some time ago i had the same problem and solved using OS commands
> for the ip address, in windows it would look something like this:
>
> (ExternalProcess defaultClass cshOne: 'ipconfig /all') readStream.
>
> That should return all the info, with a little parsing you can get the MAC,
> ip addresses, etc....
> For ubuntu i remember using something like this:
>
> (ExternalProcess defaultClass shOne: ifconfig | grep inet addr) readStream.
>
> And for the SO identification "Screen default platformName" should work
> fine, it returns a string (MS-Windows, X11, etc...).
>
> Hope it helps, Emiliano.
>



----------------------------------------------------------------
Este mensaje ha sido enviado utilizando IMP desde LIFIA.

Reply | Threaded
Open this post in threaded view
|

Re: Getting OS information

Mike Hales
Try this:

IPSocketAddress hostAddressByName: SocketAccessor getHostname

That will get you the same address that you get if you ping your hostname from the command line.  For resolving multiple ip's it takes a more complicated solution.

On 8/21/07, [hidden email] <[hidden email]> wrote:
I didn't try this method but in my linux box only root can do ifconfig.


I think the issue is that ifconfig is not in your path if you are not root.  You still should be able to run it from its location at /sbin/ifconfig. (That's how it was on my old red hat machine).

--
Mike Hales
Engineering Manager
KnowledgeScape
www.kscape.com
Reply | Threaded
Open this post in threaded view
|

Re: Getting OS information

Emiliano Pérez-3
In reply to this post by fede-7

I didn't try this method but in my linux box only root can do ifconfig.
Moreover, "ifconfig | grep inet\ addr" will list all the interfaces
including the loopback which has a different format than the other ones.


In ubuntu, i did it with no problems, i guess it depends on the distribution. Of course ifconfig will return lots of data, some will be useful and other we´ll just discard it, for instance, it will return the localhost ip, and if you have more network interfaces, it will return all of them. Of course, you´ll have to do some parsing over the stream and choose which address fits your needs.

It has to be a better way to get this information...

Actually, some time ago i tried lots of approaches and none responded the way i wanted to. Probably, the "correct" way to do it is using IPSocketAddress, but all in all i prefer to get that kind of info from the S.O. itself.
 
Cheers, Emiliano.