Can one do "source file.bash" from within ROOT?

Hello,

The short version of my question: Can one do equivalent of “source file.bash” from within ROOT?

The longer version of my question follows:

I am trying to define a number of environment variables from within ROOT using a bash file as an input. For example, I tried to do the following:

const string iniFilePath = "file.bash"; gSystem->Exec(Form("source %s",iniFilePath.c_str()));

where “file.bash” is just a number of environment variable definitions, like this:

but this approach did not work, i.e. when I try to get the variables I declared like this:

I can see, that none of the variables defined in “file.bash” can be accessed from withing ROOT.

Thank you,
Siarhei.

Hi,

When you ‘exec’ a new process is created and executed and then finishes. All environment setup there is by definition lost. You would need to execute the bash script before starting the root process or you need to set the variable using gSystem->Setenv.

Cheers,
Philippe.

Dear Philippe,

Does ROOT support importing of a set of parameters (strings, doubles, integers) from some user (physicist) friendly format (i.e. some text file)?

Sourcing a bash file was my first idea of how to conveniently import a number of parameters from a text file.

Thank you,
Siarhei.

http://root.cern.ch/download/doc/ROOTUsersGuideHTML/ch02s07.html
http://root.cern.ch/root/html/TEnv.html

Thank you very much, Pepe!!! :slight_smile: