1752567 Members
5256 Online
108788 Solutions
New Discussion юеВ

HOST in perl

 
SOLVED
Go to solution
Peter Brimacombe
Frequent Advisor

HOST in perl

thanks to H Merijn Brand for his answer to
the thread
displaying hostname on xterm window titlebar
June 6 2005

tinyurl is not allowed :(

Here is the code I put in .kshrc
HOST=$HOST; export HOST
perl -le'print "\e]0;$ENV{HOST}\7"'

from perl I printed out %ENV but HOST was not there so I added the HOST=$HOST line above it

why do I need to explicity set HOST on HP-UX?
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: HOST in perl

Hi Peter:

You are declaring and exporting the variable (and its value) called "HOST" to the running environment. THen, and only then, does Perl find it.

I would expect that the declaration and export might look like:

# HOST=$(hostname); export HOST

...or:

# HOST=servername; export HOST

If you want to see all the variables and their values in your environment, do:

perl -le 'for $key (keys %ENV) {print "$key => $ENV{$key}"}'

Regards!

...JRF...
H.Merijn Brand (procura
Honored Contributor

Re: HOST in perl

> HOST=$HOST; export HOST

Here you assign the value of $HOST to $HOST, which is a no-op

if $HOST is not set in your shell (I use the tcsh), you better do it like

export HOST=`hostname`
or
export HOST=$(hostname)

or something similar, there are so many ways to do that

> perl -le'print "\e]0;$ENV{HOST}\7"'

maybe you have another variable that reflects your hostname?

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn