Using Exec() and system commands

Hi all,

I’m fairly new to root and attempting to teach myself. Right now all I want to do is list all the files in a directory. In the command line I can do .! Dir and it lists all the files. However I want to do this by running a script/macro in root and by doing it through system commands.

What I have written (and isn’t working):

#include “Riostream.h”
#include “TSystem.h”

int Exec(){

 Exec("Dir");

}

It comes back saying the function is not defined in current scope.

Any help would be appreciated!

The TSystem declares a global object called “gSystem” which represents your OS. Exec is a method of that object, so you need to do:

gSystem->Exec("Dir");

Jean-François