in reply to source a file in Linux using perl script
If you wish to make CTC_HOME available as part of the environment in your script you can update %ENV in the code:
use strict; use warnings; local %ENV = %ENV; # NOTE: local is used here in case you wish to # restore the original %ENV in a different scope # of this script $ENV{CTC_HOME} = q{/Inf/work/}; # ... now "CTC_HOME" is available for all child # processes (via fork, system, ``, etc) of $0 (this script)
Given this idiom, you could then pass in CTC_HOME as a commandline argument or, better still, as a configuration file that you can then parse via Config::Tiny. That said, you could also just make sure the environment is set up as you wished via ~/.bash_profile before execution to avoid all of this. I am still not sure why you want to effect ~/.bash_profile. It almost seems like you're wishing to ensure an environment via command invoked via ssh. In this case, note that ssh has options that allow you to pass remote environmental viariables via the ssh command itself.
|
---|