process: Add a path to execute scripts

This commit is contained in:
Cody Northrop
2017-07-21 10:29:46 -07:00
committed by Baldur Karlsson
parent 488820e291
commit cde58e7326
4 changed files with 29 additions and 0 deletions
+2
View File
@@ -66,6 +66,8 @@ struct ProcessResult
};
uint32_t LaunchProcess(const char *app, const char *workingDir, const char *cmdLine,
ProcessResult *result = NULL);
uint32_t LaunchScript(const char *script, const char *workingDir, const char *args,
ProcessResult *result = NULL);
uint32_t LaunchAndInjectIntoProcess(const char *app, const char *workingDir, const char *cmdLine,
const rdctype::array<EnvironmentModification> &env,
const char *logfile, const CaptureOptions &opts,
+9
View File
@@ -456,6 +456,15 @@ uint32_t Process::LaunchProcess(const char *app, const char *workingDir, const c
return ret;
}
uint32_t Process::LaunchScript(const char *script, const char *workingDir, const char *argList,
ProcessResult *result)
{
// Change parameters to invoke command interpreter
string args = "-lc \"" + string(script) + " " + string(argList) + "\"";
return LaunchProcess("bash", workingDir, args.c_str(), result);
}
uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workingDir,
const char *cmdLine,
const rdctype::array<EnvironmentModification> &envList,
+9
View File
@@ -963,6 +963,15 @@ uint32_t Process::LaunchProcess(const char *app, const char *workingDir, const c
return pi.dwProcessId;
}
uint32_t Process::LaunchScript(const char *script, const char *workingDir, const char *argList,
ProcessResult *result)
{
// Change parameters to invoke command interpreter
string args = "/C " + string(script) + " " + string(argList);
return LaunchProcess("cmd.exe", workingDir, args.c_str(), result);
}
uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workingDir,
const char *cmdLine,
const rdctype::array<EnvironmentModification> &env,
+9
View File
@@ -577,6 +577,15 @@ void extractDeviceIDAndIndex(const string &hostname, int &index, string &deviceI
deviceID = c;
}
Process::ProcessResult execScript(const string &script, const string &args,
const string &workDir = ".")
{
RDCLOG("SCRIPT: %s", script.c_str());
Process::ProcessResult result;
Process::LaunchScript(script.c_str(), workDir.c_str(), args.c_str(), &result);
return result;
}
Process::ProcessResult execCommand(const string &cmd, const string &workDir = ".")
{
RDCLOG("COMMAND: %s", cmd.c_str());