I need some help trying to run a script in a backgrounded root. This script has two libraries that it needs to load, and then I need to call a function and give it two arguments. It runs fine in the interpreter but I couldn’t figure out how to get it running in the background.
Now, I’ve tried running this in command line like >root -b 'myscript.C("arg1","arg2")'but to no avail, as the libraries didn’t load, so the program doesnt run.
And then running this as > root -b 'run.C' but then that doesn’t really help me run it in the background, as I still need to manually call the myfunc, and give it arguments.
Instead of “.L myscript.C” try “.x myscript.C” (assuming that the function that you want to call is also named “myscript”):
gROOT->ProcessLine( “.x myscript.C(“arg1”, “arg2”)” );
BTW. I’m almost sure you wanted to say (in “myscript.C”):
void myscript(const char *arg1, const char *arg2)
However, when arg1 and arg2 are passed to the myscript function, myscript returns with a debug statement. Now, as far as I can tell it has something to do with not being able to read arg1 properly. To further specify, arg1 is a string that would be written similarly to “blah_U238_556k_N00.root”. The debug code ends the script if the position of “_N” is at the end of the string or if position<1 or if the length of arg 1<pos+2.
Does this have anything to do with how a string would be passed form command line into root? And yes, I did check for typos!