Hi,
actually, i gave previously the example of a simple variable only to simplify the question. What i wish is actually the definition of an alias inside root :
i mean :
root [3] gSystem->Setenv("a","3")
root [4] gSystem->Exec("echo $a")
works
but the folllowing doesn't "work":
root [1] gSystem->Setenv("amiGetDatasetEVNTInfo","'python /afs/cern.ch/atlas/software/releases/16.6.2/AtlasCore/16.6.2/Database/Bookkeeping/AMIClients/pyAMI/python/amiGetDatasetEVNTInfo.py'") root [2] gSystem->Exec("amiGetDatasetEVNTInfo") sh: amiGetDatasetEVNTInfo: command not found
while in unix :
alias amiGetDatasetEVNTInfo='python
/afs/cern.ch/atlas/software/releases/16.6.2/AtlasCore/16.6.2/Database/Bookkeeping/AMIClients/pyAMI/python/amiGetDatasetEVNTInfo.py
amiGetDatasetENVInfo
"works"
would you have a hint ?
Dario Berzano a écrit :
> Hello,
>
> each gSystem->Exec(), just like the standard C system() function, opens a new shell ("man system" says /bin/sh) with a brand new environment.
>
> But in ROOT you can set environment variables that are seen by subshells launched either via gSystem->Exec() or gSystem->OpenPipe()/GetFromPipe(): for instance you can play with the following code:
>
> // The environment variable COUNTER is set to 0
> gSystem->Setenv("COUNTER", "0");
>
> // COUNTER is incremented in subshells and its value is set to ROOT's
> // (*not* shell's) environment
> for (Int_t i=0; i<100; i++) {
> gSystem->Setenv("COUNTER", gSystem->GetFromPipe("expr $COUNTER + 1"));
> }
>
> // A subshell is spawned to echo the value of envvar COUNTER
> gSystem->Exec("echo Variable COUNTER has value $COUNTER");
>
> Please note that opening/closing 100 subshells just to increment a variable's value 100 times isn't very performance-friendly...
>
> Cheers,
> --
> : Dario Berzano
> : INFN & Università - Torino, Italy
> : Wiki: http://newton.ph.unito.it/~berzano
> : GPG: http://newton.ph.unito.it/~berzano/gpg
> : Mobile: +39 348 72 22 520
>
>
> Le 9 mars 2011 à 11:53, Marc Escalier a écrit :
>
>
>> Hello,
>>
>> in root, there are the methods TSystem::Exec() and TSystem::GetFromPipe which have the same behaviour for the following issue :
>>
>> if one does in unix :
>> a=3
>> echo $a
>> it works
>>
>> but in root :
>> if ones does :
>> gSystem->Exec("b=3);
>> gSystem->Exec("echo $b")
>> it will "forget" the b
>>
>> only this works :
>> gSystem->Exec("c=3;echo $c")
>>
>> ==>
>> is there a way to have the memory of the variables for several gSystem->Exec() commands ?
>> (in order to do some instructions ones, and some others inside a loop)
>>
>> (i tried also with export, but it doesn't help)
>>
>> thanks
>>
>
>
>
Received on Wed Mar 09 2011 - 13:36:28 CET
This archive was generated by hypermail 2.2.0 : Wed Mar 09 2011 - 17:50:01 CET