Re: for loop from a shell script

From: Akira OKUMURA <oxon_at_juno.phys.s.u-tokyo.ac.jp>
Date: Wed, 9 Dec 2009 17:44:27 +0900


Hello ROOTers again,

I found that this behavior is not appeared with ROOT 5.24.00 on both SL4.6 and Leopard. I tried 5.25.02 and the SVN trunk which do not stop after printing "9". I am not sure if this is a bug in the recent versions, but I will move to ROOT savannah.

Regards,

OKUMURA, Akira oxon_at_juno.phys.s.u-tokyo.ac.jp Department of Physics, The University of Tokyo 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
TEL/FAX +81 3-5841-4173/4059
Skype : okumura.akira

On 2009/12/09, at 15:40, Akira OKUMURA wrote:

> Hello Billy,
>
> Thank you for your advise.
>
> If I were my friend who asked me this question, I will use a .C
> macro and execute it from the shell script as you suggested. Since
> he wants to write a single script file, he used the EOF statement in
> the file instead of using an additional .C script.
>
> OKUMURA, Akira oxon_at_juno.phys.s.u-tokyo.ac.jp
> Department of Physics, The University of Tokyo
> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
> TEL/FAX +81 3-5841-4173/4059
> Skype : okumura.akira
>
> On 2009/12/09, at 15:26, W.J. Robbins wrote:
>
>> Hi:
>> Maybe I don't understand what you're trying to do ... But if you
>> want to call a macro from a shell script, you can use the -q option
>> to ROOT.
>>
>> $ more test.cxx
>> void test(){
>> for (int i=0; i<10; i++){
>> cout << i << endl;
>> }// end for over i
>> }// end test()
>>
>> $ more test.sh
>> #! /bin/bash
>>
>> echo 'here we go'
>> root -q -l test.cxx
>> echo "and I'm spent.."
>>
>> $ source test.sh
>> here we go
>> root [0]
>> Processing test.cxx...
>> 0
>> 1
>> 2
>> 3
>> 4
>> 5
>> 6
>> 7
>> 8
>> 9
>> and I'm spent..
>> $
>>
>> Best,
>> Billy
>>
>> On Wed, Dec 9, 2009 at 4:07 PM, Akira OKUMURA <oxon_at_juno.phys.s.u-tokyo.ac.jp
>> > wrote:
>> Hello ROOTers,
>>
>> Could anyone tell me how to execute this shell script properly? On
>> my Mac, the root.exe process keeps running and occupy ~100% CPU load.
>>
>> ==============
>> #!/bin/bash
>>
>> root -l <<EOF
>> for(int i=0; i<10; i++){
>> printf("%d\n", i);
>> }
>> .q
>> EOF
>> ==============
>>
>> [oxon_at_kusu ~]$ ./tmp.sh
>> end with '}', '@':abort > end with '}', '@':abort > 0
>> 1
>> 2
>> 3
>> 4
>> 5
>> 6
>> 7
>> 8
>> 9 <= ROOT stops here
>>
>> I know that the following change does work.
>>
>> for(int i=0; i<10; i++){printf("%d\n", i);}
>>
>> Thank you in advance.
>>
>> Regards,
>>
>> OKUMURA, Akira oxon_at_juno.phys.s.u-tokyo.ac.jp
>> Department of Physics, The University of Tokyo
>> 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
>> TEL/FAX +81 3-5841-4173/4059
>> Skype : okumura.akira
>>
>>
>
Received on Wed Dec 09 2009 - 09:44:37 CET

This archive was generated by hypermail 2.2.0 : Thu Dec 10 2009 - 17:50:04 CET