Saving Root Plots as PDFs from Command Line

I have written a script to iterate the graphing of plots in Root using

root -l ‘file.C(i,j)’

from the command line on my Mac, iterating i from 0 to 10 and j from 0 to 3. Thus, the script produces 44 plots in all. The inconvenient thing is that the script “pauses” after each plot displays and I have to save it manually by clicking File>Save. Is there a modification that I could add to the above command line that would have it save automatically in a given directory, provided a path and file name?


In orde to save TCanvas as image you can use the method “SaveAs” or “Print”:

And as a summary, … -cern-root


As said before you should include the print common in you script. I would also add two option in the root command line : -q and -b