# Use root in command line only

**URL:** <https://root-forum.cern.ch/t/use-root-in-command-line-only/32203>\
**Category:** ROOT\
**Created:** [January 8, 2019, 6:11pm UTC](https://root-forum.cern.ch/t/use-root-in-command-line-only/32203 "2019-01-08T18:11:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 8, 2019, 6:18pm UTC](https://root-forum.cern.ch/t/use-root-in-command-line-only/32203/2 "2019-01-08T18:18:45Z")

</div>

[ROOT User’s Guide → The C++ Interpreter Cling → Feeding Sources Files To ROOT: C++ Scripts](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#feeding-sources-files-to-root-c-scripts)

> [@Calling root from bash script](https://root-forum.cern.ch/t/calling-root-from-bash-script/21913):
>
> Dear root experts, I have several root macros which I want to compile and run in root. I have made a bash script for it. The simple example of the script is Name:RunMacro\_1\_to\_3.sh and it contains following lines root -b -l \<\<EOF .L Job\_PsiRatio\_Eff\_PP\_Numbers\_1.C+g PsiRatio\_Eff\_PP\_Numbers\_1(); .L Job\_PsiRatio\_Eff\_PP\_Numbers\_2.C+g PsiRatio\_Eff\_PP\_Numbers\_2(); .L Job\_PsiRatio\_Eff\_PP\_Numbers\_3.C+g PsiRatio\_Eff\_PP\_Numbers\_3(); EOF To run it, I do in command prompt ./RunMacro\_1\_to\_3.sh …

> [@ROOT commands from bash script](https://root-forum.cern.ch/t/root-commands-from-bash-script/27572):
>
> Hi, I want to write a bash script that runs some root commands. The script is #!/bin/bash for i in `seq 1 235`; do root -b -q .x masses\_wrong\_ratio\_opt.C("/home/george/Desktop/wrong\_weights/output/benchmark\_ttH\_1.dat.out") # runs the macro script that creates the root files .q # exits root mv ratio\_wrng.root ratio\_wrng\_$i.root …

> [@Ask: how to transfer the parameter for the root scritpt](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535):
>
> Hello rooters, I will use an example to show my question: my root script (DrawDiLepPlots.C) is like following: void DrawDiLepPlots(int period=-1 ) { cout\<\<" period: "\<\<period\<\<endl; } If you run command-“root DrawDiLepPlots.C”, the output is: period: -1 May I ask how could I change the period by this command line mode? I remember it is something like “root DrawDiLepPlots.C ( 3 )”. But it doesn’t work. Can anybody tell me how to do it? Thank you in advance! Best regards Lei

---

_[View the full topic](https://root-forum.cern.ch/t/use-root-in-command-line-only/32203)._
