source bash config from perl code

source bash config from perl code

Tzafrir Cohen tzafrir at cohens.org.il
Wed Sep 30 17:09:17 IST 2009


On Wed, Sep 30, 2009 at 04:48:41PM +0200, Alexander Indenbaum 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.

Here's something written by another member of this list after a certain
shell script has been converted to perl but was still required to use
the original configuration:

http://svn.asterisk.org/svn/zaptel/tags/1.4.12.1/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm

It runs a separate sh subprocess with a controlled environment which
sources the file and then prints out a pre-defined set of variables. The
script then parses out the values of those variables.

-- 
Tzafrir Cohen         | tzafrir at jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir at cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend



More information about the Linux-il mailing list