Skip to content

Commit

Permalink
[Utils] Add three rare to find convenience functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 authored and gganis committed Nov 23, 2021
1 parent 3f54912 commit 3f2ea4f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/XrdOuc/XrdOucProg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,29 @@ int XrdOucProg::Run(XrdOucStream *Sp, const char *argV[], int argC,
return 0;
}

/******************************************************************************/

int XrdOucProg::Run(const char *argV[], int argC, const char *envV[])
{
XrdOucStream cmd;
char *lp;
int rc;

// Execute the command
//
rc = Run(&cmd, argV, argC, envV);
if (rc) return rc;

// Drain all output
//
while((lp = cmd.GetLine()))
if (eDest && *lp) eDest->Emsg("Run", lp);

// All done
//
return RunDone(cmd);
}

/******************************************************************************/

int XrdOucProg::Run(XrdOucStream *Sp, const char *arg1, const char *arg2,
Expand Down
7 changes: 5 additions & 2 deletions src/XrdOuc/XrdOucProg.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ XrdOucStream *getStream() {return myStream;}
// additional arguments to be appended to the existing ones. The
// method also allows envars to be set in forked process via envV vector
// which contains strings "var=val" and terminaes with a null pointer.
// When using the form without a stream pointer, command output is thrown away.
//
int Run(XrdOucStream *Sp, const char *argV[], int argc=0,
const char *envV[]=0);
int Run(XrdOucStream *Sp, const char *argV[], int argc=0,
const char *envV[]=0);

int Run(const char *argV[], int argC, const char *envV[]=0);

// Run executes the command that was passed via Setup(). You may pass
// up to four additional arguments that will be added to the end of any
Expand Down

0 comments on commit 3f2ea4f

Please sign in to comment.