Re: Looking for a TSystem example

From: Fons Rademakers <Fons.Rademakers_at_cern.ch>
Date: Tue, 20 Jun 2006 16:19:05 +0200


Hi Nicolas,

   just use TSystem::OpenPipe() and ClosePipe(). See this example:

root [0] FILE  *pipe = gSystem->OpenPipe("date", "r");
root [1] TString d
root [2] d.Gets(pipe)

(Bool_t)1
root [3] d
(class TString)"Tue Jun 20 16:17:50 CEST 2006" root [4] gSystem->ClosePipe(pipe);

Cheers, Fons.

Nicolas Arnaud wrote:
>
> Hi,
>
> I'm looking for a short macro showing how to use the TSystem class to
> execute a system command (for instance |date| as a trivial example)
> inside a ROOT macro and to get the output of the command (not the
> status), for instance in an array of string/char.
>
> Thanks in advance,
>
> Nicolas
>

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers_at_cern.ch              Phone: +41 22 7679248
WWW:    http://fons.rademakers.org           Fax:   +41 22 7669640
Received on Tue Jun 20 2006 - 16:19:12 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:59 MET