BradV has asked for the wisdom of the Perl Monks concerning the following question:
I have a bourne shell script that sets a bunch of environment variables. From another bourne shell script I would just call as: . /usr/local/env.sh
I've written a perl script that I need to get those same environment variables set in. I tried doing:
my %BB_ENV = `/bin/sh . /usr/local/env.sh`; %ENV = { %ENV, %BB_ENV };
Any ideas how I could achieve this?
Thanks!
Hopefully, I am updating this correctly. :)
I couldn't get any of the suggestions to work. The file has comments, "export" lines, etc. Not a simple "Var=value" type of setup. So, I wound up doing this:
#!/bin/sh if [ -f /usr/local/env.sh ]; then . /usr/local/env.sh fi exec perl -wx "$0" "$@" #!/usr/bin/perl -w ....
That is working. Thanks for all of the suggestions!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get environment variables from a bourne file
by kennethk (Abbot) on May 12, 2011 at 14:19 UTC | |
by choroba (Cardinal) on May 12, 2011 at 14:45 UTC | |
by BradV (Sexton) on May 12, 2011 at 14:30 UTC | |
|
Re: get environment variables from a bourne file
by toolic (Bishop) on May 12, 2011 at 14:20 UTC | |
|
Re: get environment variables from a bourne file
by Anonymous Monk on May 12, 2011 at 14:03 UTC | |
|
Re: get environment variables from a bourne file
by anonymized user 468275 (Curate) on May 12, 2011 at 14:26 UTC |