linux - Perl script, how to source an environment variables from .bash_profile -
i need quick advice on perl script. created script calls other perl scripts , many other shell scripts within those. problem i'm facing, trying make run on universal level setting 1 environment variable.
this on linux rhel/centos way...
so add variables .bash_profile , works without issue if manually source file first, run perl script! is, ok, script automate part instead of needing extra, manual sourcing step.
so script looks this... in short
#!/usr/bin/perl use warnings; use strict; `/bin/bash ~/.bash_profile`; blah blah blah more code etc;
when launching main script (where part of code is) works no problem. it's subsequent calls made other scripts failing...as if not passing variable on rest of scripts.
any ideas??
thanks,
- the easiest way set environment variables within perl
$env{"name"}=...
. these variables propagated automatically programs started within perl script, no matter if perl or shell scripts - alternatively open .bash_profile, parse within perl, extract variables , set them again within perl
$env
. error prone because there might several ways declare variables. - or spawn shell, reads .bash_profile , calls
env
afterwards. read , parse output shell. similar previous proposal, output have parse more defined. - or use shell script sources .bash_profile , spawns perl script.
Comments
Post a Comment