Hi Jianglai, the TString::Fgets() has changed in the current cvs head to TString::Gets() to have a bit better name. Since we had not officially released or announced this new method (except to you :-)) we decided we still could make this change. So take the latest head and use Gets() instead of Fgets(). Cheers, Fons. On Thu, 2003-09-04 at 16:38, Fons Rademakers wrote: > Hi Jianglai, > > you can use pipes to run the command and directly read the output, for > example: > > ... > FILE *p = gSystem->OpenPipe(Form("ps -u %s", user), "r"); > TString out; > Bool_t myproc = kFALSE; > while (out.Fgets(p)) { > if (out.Index("myprog") != kNPOS) { > myproc = kTRUE; > break; > } > } > gSystem->ClosePipe(p); > ... > > TString::Fgets() is a recent addition so use the latest version. > > > Cheers, Fons. > > > > Dear ROOTers, > > > > I am implementing a launcher button on a ROOT GUI program to invoke > > another executable. But I like to test whether the process has been > > running already. A quick and dirty solution I am using is > > (in pseudo-code language) > > > > -- gSystem->Exec("ps -u user | grep program >.tmp"); > > -- Parse the tmp file and find if program exists > > > > Is there a better way in TSystem (or whatever ROOT class) that > > might handle the system calls in a more elegant way? > > > > Thanks in advance! > > > > Jianglai > > -- 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 : Thu Jan 01 2004 - 17:50:15 MET