Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
Hi fellow monks!
I have a shell script (set_env.sh) which sets some variables. It is usually sourced from other shell scripts.
Now I have a perl script which needs these settings too. So usually I call my script like this:
. ./set_env.sh ./myscript
But I don't like this ;-) One way would be to use a wrapper script containing these 2 commands, but I don't like it too much.
So is there a way to get my script to call set_env.sh and use its settings?
My idea was to do it something like this (incomplete pseudocode) at the very beginning of the code of myscript
#!/usr/bin/perl if ( not defined $ENV{'environment_set'} ) { exec ". ./set_env.sh ; environment_set=1 ./myscript"; } # script follows here
Is there a cleaner way? What do you suggest?
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to set (environment) variables for the script
by mr_mischief (Monsignor) on Jun 10, 2010 at 13:48 UTC | |
Re: How to set (environment) variables for the script
by walto (Pilgrim) on Jun 10, 2010 at 13:46 UTC | |
Re: How to set (environment) variables for the script
by Skeeve (Parson) on Jun 10, 2010 at 14:58 UTC | |
Re: How to set (environment) variables for the script
by Argel (Prior) on Jun 10, 2010 at 21:49 UTC | |
by Skeeve (Parson) on Jun 11, 2010 at 08:21 UTC |
Back to
Seekers of Perl Wisdom