# Root or Cling and Bash scripting

**URL:** <https://root-forum.cern.ch/t/root-or-cling-and-bash-scripting/57118>\
**Category:** Newbie\
**Created:** [November 14, 2023, 6:58pm UTC](https://root-forum.cern.ch/t/root-or-cling-and-bash-scripting/57118 "2023-11-14T18:58:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cw2636](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@cw2636](https://root-forum.cern.ch/u/cw2636)\
**Post date:** [November 14, 2023, 6:58pm UTC](https://root-forum.cern.ch/t/root-or-cling-and-bash-scripting/57118/1 "2023-11-14T18:58:55Z")

</div>

I wanted to create an executable, that i can call in a bash script, with c++ code, which when i run the bash scripts will interprete the c++ code, how can i achieved that.  
Bash scripts will look like

```auto
#! /usr/local/bin/test_executable

int main ( int argc, char *argv[] )
{
  
    cout << " SUCCESSFUL" << endl;

  exit ( 0 );
}

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 15, 2023, 8:30am UTC](https://root-forum.cern.ch/t/root-or-cling-and-bash-scripting/57118/3 "2023-11-15T08:30:35Z")

</div>

Welcome to the ROOT forum.

You can create the `.C` macro `mymacro.C` and in your shell script you do:

```auto
root -l -b -q maymacro.C

```

---

<div class="post-metadata">

**Author:** ![cw2636](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@cw2636](https://root-forum.cern.ch/u/cw2636)\
**Post date:** [November 15, 2023, 2:13pm UTC](https://root-forum.cern.ch/t/root-or-cling-and-bash-scripting/57118/4 "2023-11-15T14:13:24Z")

</div>

The goal is to create a c++ executable, by linking so many files and call this executable in the bash or shell scripts which will allow me to execute the c++ code in the scripts

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 17, 2023, 8:40am UTC](https://root-forum.cern.ch/t/root-or-cling-and-bash-scripting/57118/5 "2023-11-17T08:40:18Z")

</div>

Simply create the executable and call it from the the shell script. Ie:

You put the C++ code into a file `test_executable.cxx`, then you compile and link it. You will get an executable `test_executable`, and you call it for the script.
