source bash config from perl code
Shlomi Fish
shlomif at iglu.org.il
Wed Sep 30 18:26:35 IST 2009
On Wednesday 30 Sep 2009 17:52:34 Oleg Goldshmidt wrote:
> 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? ;-)
>
According to http://en.wikipedia.org/wiki/Abstraction_layer :
A famous aphorism of David Wheeler goes: All problems in computer science can
be solved by another level of indirection;[2] this is often deliberately mis-
quoted with "abstraction" substituted for "indirection". Kevlin Henney's
corollary to this is, "...except for the problem of too many layers of
indirection."
This is http://en.wikipedia.org/wiki/David_Wheeler_%28computer_scientist%29
who passed away at 13 December 2004 . He should not be confused with these two
other programmers called "David Wheeler" who are still alive and well
("ve'sheyibadlu lehayim arukim"):
* http://www.dwheeler.com/
* http://search.cpan.org/~dwheeler/ ; http://www.justatheory.com/
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Original Riddles - http://www.shlomifish.org/puzzles/
Chuck Norris read the entire English Wikipedia in 24 hours. Twice.
More information about the Linux-il
mailing list