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