I use this for the hostname:

use Sys::Hostname;
my $hostname = hostname();  # Captures hostname correctly on all systems

and this for to check for root:

if ( $< != $> || $< != 0 ) {                # If you are not root...
  die "*** This script must be run as root. \n
       *** Login as root and try again\n";
}

Jamie

-----Original Message-----

  my $machine = $ENV{HOSTNAME};

martin



Mark Johnson wrote:

> Is there another way to get access to the environment variables...
this
> works, but it seems kind of kludgy..
> 
> my $machine = `echo \$HOSTNAME`;
> 
> Also, is there a way to detemine whether the script is being executed
by
> root?
> 
> I tired doing:
> 
> my $is_root = `echo \$UID`
> 
> but for some reason this doesn't work, but it works in a bash
script...it
> appears that $UID isn't available or something...
> 
> thanks!
> 
> 
> 
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to