Re: [ROOT] How to run root in batch?

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Sun Sep 23 2001 - 11:40:52 MEST


Another nice alternative is to specify root as script executor instead
of /bin/sh. Try for example the shell script:

#! /user/rdm/root/bin/root.exe
{
   for (int i = 0; i < gApplication->Argc(); i++)
      printf("argv[%d]: %s\n", i, gApplication->Argv(i));

   gROOT->LoadMacro("$ROOTSYS/tutorials/zdemo.C");
   zdemo();

   //gApplication->Terminate(0);
}

Modify the root.exe location, save as bla make bla executable and
run ./bla


Cheers, Fons.



On Saturday 22 September 2001 17:39, Andre Holzner wrote:
> Hi,
>
> > #!/bin/sh
> > . /usr/local/etc/setups.sh
> > #
> > setup root
> > #
> > cd /usr/e781/data05/scratch/dauwe/
> > # do root in batch mode and quit when finished
> > $ROOTSYS/bin/root -b -q {
>
> This makes root to search for the file '{' and then execute it.
>
> >       /usr/e781/data05/scratch/dauwe/Myxc.C;
> >       Myxc t;
> >       t.Loop();
> >     }
>
> These lines are interpreted by /bin/sh again, not by root.
>
> If you want to use lines from the script as input
> to root, use a 'here document':
>
> $ROOTSYS/bin/root -b <<EOF
> {
>       gSystem->Load("/usr/e781/data05/scratch/dauwe/Myxc.C");
>       Myxc t;
>       t.Loop();
> }
> EOF
>
> (instead of EOF, you can also use a different string).
> The -q must be left out in this case (because there is no
> script name given on the command line and root exits
> automatically when seeing end of file).
>
>
> good luck,
>
> André

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:00 MET