I am executing a shell command in my ROOT code using gSystem
which returns an int
, as seen here gSystem->Exec(). But when I try to assign the output to a in code variable the assignment doesn't happen.
int low_edge = 0;
low_edge = gSystem->Exec("ls ./folder | egrep -o '[0-9]{3,3}' | head -1");
I have tried also gSystem->Exec("ls ./folder | egrep -o '[0-9]{3,3}' | head -1") >> low_edge
, but it didn't work out.
Am I missing something obvious?
The return value of gSystem->Exec() is 0 or -1 depending on if the command was successful.
What you want is:
TString GetFromPipe(const char* command)
should work, you just need to convert TString to int.