Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Read UNIX environment variable

by DrHyde (Prior)
on Feb 09, 2011 at 10:57 UTC ( [id://887168]=note: print w/replies, xml ) Need Help??


in reply to Re: Read UNIX environment variable
in thread Read UNIX environment variable

An obvious improvement is to notice that \s contains \n. And also that 'use Env' is completely useless in this case.

Replies are listed 'Best First'.
Re^3: Read UNIX environment variable
by fisher (Priest) on Feb 09, 2011 at 13:25 UTC
    Well, thank you, captain.
Re^3: Read UNIX environment variable
by Anonymous Monk on Feb 09, 2011 at 11:01 UTC
    Thanks, will I be able to access env variables if my perl code gets run from cron?

      Yes and no.

      You can read an environment, but as cron jobs run their own environment, you need to load the environment you want. See Get default login environment.

        Thanks for the heads up. I'm a bit confused though. In he example you link to do I need to change the rest of my script or does $ENV get overwritten by the function? Do I just call %ENV = (%ENV, get_login_env()); and continue as I did before With my $varname = $ENV{'ENV_VAR_NAME'};? Thanks

      You can access environment variables in a script run as a cron job but take note that cron jobs often have only a sub-set of the environment available to a user shell. For instance, you will likely have a minimal $PATH under cron. It might be worth writing a small script to dump the environment to a file then run it as a cron job to see what's available.

      I hope this is helpful.

      Cheers,

      JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://887168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found