Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Sourcing shell scripts

by sg (Pilgrim)
on Oct 20, 2007 at 05:11 UTC ( #646136=note: print w/replies, xml ) Need Help??


in reply to Sourcing shell scripts

Unless I am misunderstanding what you are doing,

use Env;
should give you everything you need. On Windows, I can set environment variables from inside perl via $Env{var}=<value>, and these environment variables will be visible to subsequent `backtick` calls.

Replies are listed 'Best First'.
Re^2: Sourcing shell scripts
by tuxz0r (Pilgrim) on Oct 20, 2007 at 05:55 UTC
    I can always set an environment variable using the built in %ENV on Unix (or you mention 'use Env' on Windows) but the idea was to make use of our existing shell environment (which is built dynamically when our software package is installed) so we can have a single source of environment settings (easier to debug, modify, etc.). We needed these shell environments set outside of the Perl script and we didn't want to duplicate them by having another Perl script to set the environment just for Perl.

    The code snippet posted will source this shell environment file prior to exec'ing the Perl script, that way it's available to the Perl code. We don't run these programs by hand, they run from a cron job, and we previously had to write a shell wrapper to perform the same function that the snippet does automatically for us. Plus, now any of our shell debugging tools and utilities are using the exact same environment settings as the actual Perl scripts that run the system. Which was the whole point.

    I hope this makes sense.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2022-12-06 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?