[vtkusers] using vtksysProcess

Bill Lorensen bill.lorensen at gmail.com
Mon Mar 10 14:57:10 EDT 2008


Dean,

I think each command needs to be a separate char *:

 vtkstd::string executable = "my_app.exe";
   vtksysProcess* process = vtksysProcess_New();
   vtkstd::vector<const char*> commandLine;
   commandLine.push_back(executable.c_str());
   commandLine.push_back("/arg1");
   commandLine.push_back("/arg2");
   commandLine.push_back(0);
   vtksysProcess_SetCommand(process, &commandLine[0]);
   vtksysProcess_Execute(process);

Bill


On Mon, Mar 10, 2008 at 9:45 AM, Dean Inglis <dean.inglis at sympatico.ca> wrote:
>
> I want to use vtksysProcess to execute a windows command line
> utility, but am not sure how to do this.  Here is my code so far;
>
>   vtkstd::string executable = "my_app.exe";
>   vtksysProcess* process = vtksysProcess_New();
>   vtkstd::vector<const char*> commandLine;
>   commandLine.push_back(executable.c_str());
>   commandLine.push_back("/arg1 /arg2");
>   commandLine.push_back(0);
>   vtksysProcess_SetCommand(process, &commandLine[0]);
>   vtksysProcess_Execute(process);
>
>   char* data;
>   int length;
>   int pipe =  vtksysProcess_WaitForData(process, &data, &length, NULL);
>   vtksysProcess_Delete(process);
>
> When I run this, my_app complains with:
>
> Invalid argument/option - '/arg1 /arg2'
>
> 1) How do I pass args to my_app ?
> 2) How do I retrieve the string(s) of information that my_app is supposed
> to generate?
>
> thanks,
> Dean
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list