which states in an example that to pass a string as a parameter you’re supposed to do:
root -b -q 'myMacro.C("text")' > myMacro.log
I have a root script with two string arguments writeHVDataPlots(const string data_location, const string data_timestamp) which plots and writes TGraphs in a Root file. I’m trying to run it from command prompt:
You may need to use more escape characters for all the backslashes. Try to create a macro that just prints the argument, and call ROOT with that macro, then make sure that the escaping is correct. I don’t use Windows, but maybe using
It looks like ROOT thinks ' is part of the name of the macro.
With some clever usage of double quotes and escaping I think you can make things work with just double quotes. If that works, this might be a bug report for ROOT’s command line parsing logic.
First of all, to clarify, I’ve made a mistake in the first place. For a root script to run in Windows it would need the path in slashes and not in backslashes as in Windows paths or else it gives an error. It’s really weird but since it works, that’s fine.
However, I repeated all the steps and the problem persists so I’ve tried it with other scrips of mine and it works fine without a parameter. When I try to pass a string inside, as @eguiraud has noted, it again seems as if ROOT reads the first ' as part of the macro. I tried to use escaping of some sort but couldn’t get it to work.