How to quit ROOT enviroment automatically?

Dear ROOT Expert:

I have a bash file to run several root files together:

cat 1.sh:

root A1.c
root A2.c
root A2.c

When I try to source 1.sh, root will be started to run A1.c, but when it’s finished, it’s stucked there and will not go to A2.c. It needs a manuall work to type ‘.q’ , how can I avoid this manual typing work? e.g. is there a way to quit ROOT automatically?

Thanks,Gang

It’s easy.

I’d suggest making a flag on the main part, and then having a check on if the flag is passed. Put an if statement for the Terminate call if the automatic flag is passed. Or if you don’t want to do flags, just make it a Bool_t for the function and call it from the shell like:

Dear Daid:

Many thanks. Now I can quit root enviroment automatically.

Cheers,Gang

[quote=“crazyqg”]Dear ROOT Expert:

I have a bash file to run several root files together:

cat 1.sh:

root A1.c
root A2.c
root A2.c

When I try to source 1.sh, root will be started to run A1.c, but when it’s finished, it’s stucked there and will not go to A2.c. It needs a manuall work to type ‘.q’ , how can I avoid this manual typing work? e.g. is there a way to quit ROOT automatically?

Thanks,Gang[/quote]

You can run root with the -q option

root -q A1.C

Will run the macro and then quit without having to change the macro.

Cheers,
Charles