OESF Portables Forum

Everything Else => General Support and Discussion => Zaurus General Forums => Archived Forums => Software => Topic started by: boosalis on July 09, 2004, 01:30:41 pm

Title: Getting name of handheld
Post by: boosalis on July 09, 2004, 01:30:41 pm
I would like to get from the  environment variable HOSTNAME the name of the handheld, but it is not set.  I can currently hard code it in the zaurus .profile.  But is there a better way to do this.  I think there is a file in /etc called HOSTNAME, but from what I can gather you can set this value to anything and it never changes any thing.

Thank you for any help

-david
Title: Getting name of handheld
Post by: tumnus on July 09, 2004, 05:36:55 pm
What about using the 'hostname' command?
Title: Getting name of handheld
Post by: boosalis on July 09, 2004, 07:17:29 pm
I am doing this from source code,  Sure I guess I could execute getHostname and have it print to a file then read the file.  But I would rather use something like

char *hostname;
hostname = getenv("HOSTNAME");

Which works on linux desktop machines

-David
Title: Getting name of handheld
Post by: doseas on July 09, 2004, 08:06:20 pm
In my /etc/rc.d/rc.local, I added the following line:
# set default hostname
/bin/hostname zaurus

this apparently causes the OS to set the proper value in /etc/HOSTNAME and also the $HOSTNAME env var.