Re: shellscript executing a root macro with variables

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Sat, 10 Mar 2007 11:40:13 +0100


Hi,

an alternative is e.g. this test.sh (a bash script)   root -l -b -q "$@"
which you run as
  ./test.sh 'test.cxx+("c d", "e f")'
The "$@" takes care of args with spaces, and it works with ACLiC, too.

Cheers, Axel.

Tom Roberts wrote:
> John Zoidberg wrote:

>> I would like to create a shellscript which can take any ROOT macro
>> (with 0,1 or more variables) as argument, launch root, execute the
>> macro with the given arguments and write the output into a .out file
>> and the errors into a .err file.

>
> Here's how I pass arguments to my Root macro (this is a bash script):
> ARGS="$*" $ROOTSYS/bin/root -n -l macro.C
>
> The ARGS are names of Root files to read:
> // open files given in environment variable ARGS
> const char *args = gSystem->Getenv("ARGS");
> if(!args) args = "";
> TObjArray *files = TString(args).Tokenize(" \t");
> for(int i=0; i<files->GetEntries(); ++i) {
> TObjString *s = files->At(i);
> if(!s || *s->String().Data() == '\0') continue;
> TFile *f = new TFile(s->String().Data(),"READ");
> if(f->IsZombie())
> new TGMsgBox(gClient->GetRoot(),window,"Error",
> "File could not be opened!"); //self-deleting
> }
> files->Delete();
> delete files;
>
> Yes, this fails if any filename contains a space....
>
>
> Tom Roberts
>
>
Received on Sat Mar 10 2007 - 11:40:18 CET

This archive was generated by hypermail 2.2.0 : Sat Mar 10 2007 - 17:50:01 CET