RE: [ROOT] help

From: Valeri Fine (fine@bnl.gov)
Date: Fri Aug 01 2003 - 15:26:36 MEST


Hello,
You may try 

http://root.cern.ch/root/htmldoc/TSystem.html#TSystem:Setenv

method to set that.

However this is still shell specific.
I think it is not a good idea to provide the communication between two
processes via the shell env variable. It looks simple but it is error
prone. 

I agree with Olivier's statement
"I guess you should find another way to send the run number outside
ROOT"

Best regards, Valeri

> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]
> On Behalf Of Olivier Couet
> Sent: Friday, August 01, 2003 5:25 AM
> To: Meiwen
> Cc: rt
> Subject: Re: [ROOT] help
> 
> 
> Hello,
> 
>  I think your problem comes from the fact that gSystem->Exec starts a
new
> shell. So your variable is defined during the short time this new
shell
> is alive but then doesn't exist in the shell in which ROOT started. In
> order to demonstrate this effect I have created the following very
simple
> example:
> 
> --- file runnb.C
> {
>    gSystem->Exec("export AAA=hello");
>    printf("%s\n", gSystem->Getenv("ROOTSYS"));
>    printf("%s\n", gSystem->Getenv("AAA"));
> }
> ---
> 
> The output of this macro is:
> 
> root [0] .x runnb.C
> /home/couet/rootpro
> 
> root [1]
> 
> as you see the variable ROOTSYS is known because it was set in the
shell
> in which ROOT started, but AAA is blank because the shell in which it
was
> set finished. I guess you should find an other way to send the run
number
> outside ROOT. May be write it into a file ?
> 
>  Cheers,         Olivier
> 
> 
> On Fri, 1 Aug 2003, Meiwen wrote:
> 
> > Dear rooters
> >      I need to get the value of parameter Run_Number and have
written a
> small test program as following:
> >
> > {
> > gROOT->Reset();
> >   char *RUNNR = new char[100];
> >
> >   sprintf(RUNNR, "export Run_Number=`getvalue runctl@krunc runnr |
grep
> value | awk '{print $3}'`");
> >
> >   gSystem->Exec(RUNNR);
> >
> >   cout << "Run_Number = " << gSystem->Getenv("Run_Number") << endl;
> >
> >
> > }
> >
> > The problem is the result of Run_Number is empty. But when I
executed
> the command
> >
> > export Run_Number=`getvalue runctl@krunc runnr | grep value | awk
> '{print $3}'`
> > echo $Run_Number
> >
> > I got the real value Run_Number. Could you help me?
> >
> > thanks a lot                                                    Wen
Mei
> >
> 
> --
> Org:    CERN - European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23 - Switzerland                     Mailbox:
J25910
> E-Mail: Olivier.Couet@cern.ch                            Phone:   +41
22
> 7676522
> WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41
22
> 7677155



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET