i want to open a shell of a different program from the bash script (specifically root - a software for physicists) and execute several commands in a row.
I know to enter one command:
echo ".L mymacro.C" | root -l
but i need to enter several commands one by one without closing the root shell (root is not a root user, but an interactive shell for a different program)
I have tried with the parentheses, but it didn't succeed:
(echo ".L mymacro.C"; echo "myClass a";echo "a.Loop") | root -l
I need those 3 commands entered in a root shell one by one:
mymacro.C
myClass a
a.Loop
How could i do this from a bash script?
Thank you very much.
Perhaps a here document might work:
$ root -l <<EOF
.L mymacro.C
myClass a
a.Loop
EOF
Can you not simply do:
echo -e ".L mymacro.C\nmyClass a\na.Loop" | root -l
This will send the data line by line to the root shell.
Or if you really want to do it one by one, you can always loop as follows:
Code removed thanks to mhawke's remark
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With