I don’t remember if HOSTNAME worked in the past.  Maybe that’s why we created the custom variable to begin with.

But this solution works great, actually.  Thanks Joel!

PS:  I would still love to know why HOSTNAME seems to be treated differently than other vars as far as getenv() is concerned…if anyone out there has any theories...

—ss

[ - ]  Scott Smallwood - Associate Professor - University of Alberta  [ - ]

On Sep 19, 2015, at 11:44 AM, Joel Matthys <jwmatthys@gmail.com> wrote:

Hmm, the same happens for me. Perhaps $HOSTNAME is null until polled, so it is generated upon request by the command line call?

One possible workaround is to set an env variable right before launching chuck, eg:

NETNAME="$HOSTNAME" chuck myfile.ck

and access Std.getenv("NETNAME") in your code.

I wasn't aware of setenv or getenv before. Did getenv("HOSTNAME") work in the past?

Joel

On 09/18/2015 08:53 PM, Scott Smallwood wrote:

Hey Chuckians…

Question for those who use Std.setenv().  I’m trying to resurrect some old code of mine that made use of a special environment variable we used to use in plork to identify machines over the network.  In short:  this was a variable we called “NET_NAME”, in which we specified the network name address (i.e. blah.local) on our local area wireless network.

What I’m wondering is this:  in UNIX, there is usually a variable already in existence called “HOSTNAME”.  For example, on my mac, when I type “echo $HOSTNAME” in the terminal, it returns a string that contains the name of my machine with .local appended to it.

However, when I try to recall this variable using Std.setenv(), I get nothing.

Anyone have any ideas here?

—ss

[ - ]  Scott Smallwood - Associate Professor - University of Alberta  [ - ]



_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users