# Ask: how to transfer the parameter for the root scritpt

**URL:** <https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535>\
**Category:** ROOT\
**Created:** [December 20, 2011, 11:09pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535 "2011-12-20T23:09:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lezhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3bc359/32.png) [@lezhang](https://root-forum.cern.ch/u/lezhang)\
**Post date:** [December 20, 2011, 11:09pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/1 "2011-12-20T23:09:54Z")

</div>

Hello rooters,

I will use an example to show my question:

1. my root script (DrawDiLepPlots.C) is like following:

void DrawDiLepPlots(int period=-1 ) {  
cout\<\<" period: "\<\<period\<\<endl;  
}

1. 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

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [December 20, 2011, 11:28pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/2 "2011-12-20T23:28:14Z")

</div>

No spaces allowed in the call, try:  
root DrawDiLepPlots.C(3)

---

<div class="post-metadata">

**Author:** ![lezhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3bc359/32.png) [@lezhang](https://root-forum.cern.ch/u/lezhang)\
**Post date:** [December 21, 2011, 9:05am UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/3 "2011-12-21T09:05:47Z")

</div>

Hi Pepe,

Thanks a lot! It works. 😃

Cheers

Lei

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [December 21, 2011, 11:10am UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/4 "2011-12-21T11:10:41Z")

</div>

Actually, you have three possibilities:

root -l -b -q DrawDiLepPlots.C(3)  
root -l -b -q DrawDiLepPlots.C\ (\ 3\ )

root -l -b -q "DrawDiLepPlots.C(3)"  
root -l -b -q “DrawDiLepPlots.C ( 3 )”

root -l -b -q 'DrawDiLepPlots.C(3)'  
root -l -b -q ‘DrawDiLepPlots.C ( 3 )’

Added: See, for example, [ROOT User’s Guide -\> Getting Started -\> Start and Quit a ROOT Session](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#start-and-quit-a-root-session)

---

<div class="post-metadata">

**Author:** ![lezhang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/3bc359/32.png) [@lezhang](https://root-forum.cern.ch/u/lezhang)\
**Post date:** [December 21, 2011, 12:18pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/5 "2011-12-21T12:18:30Z")

</div>

Hi Pepe,

Thanks for your detailed explanation.

May I ask whether there is a official document that mention these methods?  
Because I have searched many place, e.g. user guide, tutorial. But maybe because of my careless, I didn’t find these methods.

Cheers

Lei

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [February 3, 2012, 3:57pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/6 "2012-02-03T15:57:55Z")

</div>

Hi Lei,

Those methods are described in the shell’s (bash, tcsh) manual and guides as they are the way that those tools provide to escape their own special characters ( parenthesis, quotes, etc.)

Cheers,  
Philippe.

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [May 14, 2015, 12:53pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/7 "2015-05-14T12:53:37Z")

</div>

Hi,

and what if the parameter is not an integer, but a char\* or a string? E.g., users’ guide has this example:

```auto

```

, and I want to pass the “text” into myMacro.C from another process. I.e., to create a variable, let’s say

```auto

```

, and pass it to myMacro.C, how do I do that with all these quotation marks?

Thanks!

---

<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:** [May 14, 2015, 1:20pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/8 "2015-05-14T13:20:34Z")

</div>

Try:  
root -l -b -q ‘myMacro.C("’${dateAndTime}’")’

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [May 14, 2015, 1:26pm UTC](https://root-forum.cern.ch/t/ask-how-to-transfer-the-parameter-for-the-root-scritpt/13535/9 "2015-05-14T13:26:01Z")

</div>

Ok, that works, thanks!
