source bash config from perl code
Oleg Goldshmidt
pub at goldshmidt.org
Wed Sep 30 17:52:34 IST 2009
On Wed, Sep 30, 2009 at 4:48 PM, Alexander Indenbaum
<alexander.indenbaum at gmail.com> wrote:
> Hello,
>
> I have bash script which alters environment, kind of configuration,
> let's say config.env.
>
> I'd like to import this environment in context of perl script. How do
> I do equivalent to 'source config.env' from perl code? I mean I could
> just run bash in subprocess, but it would not alter perl process
> environment.
>
> Any thoughts?
My first thought is to create a wrapper bash script that will source
config.env and call the perl script (or an arbitrary command specified
as the tail of the command line, if you wish) in case of success. I am
not an expert in perl but I suspect you can then call the wrapper
script using system()/exec()/friends from other perl code.
"There is no problem in computer science that cannot be solved with
another layer of indirection." Who said that? ;-)
Once again, I am not a perl expert, but AFAIK perl does some checking
on some parts of the environment (PATH, CDPATH, IFS, ENV, BASH_ENV,
etc.) for security reasons, so you should make sure that your
config.env does not make perl suspicious.
--
Oleg Goldshmidt | pub at goldshmidt.org
More information about the Linux-il
mailing list