On Thursday 31 January 2008 17:32:26 William A. Rowe, Jr. wrote: > Antonia Tugores wrote: > > I'm having some troubles with apr_process_create in win32 platforms. When > > I try to execute cmd.exe the result is a message like "The system can't > > find the specified path". The command type I used is APR_SHELLCMD_ENV, so > > cmd is in the path. With other applications it worked fine, the only one > > that fails is cmd.exe. > > > > By the way, I am not using pipes nor std_out/err files, and the apr > > version I use is 1.2.11. > > There's your problem, I'm guessing. Set up (even to "NUL" file) your std > in/out/err, and cmd.exe should stop wigging out. > > cmd.exe can't run in a vaccum. Also, if it's shellcmd, why would you > invoke a shell of a shell? That's a whole lot of indirection. > APR_PROGRAM_ENV sounds like what you wanted.
The problem is not the shell into a shell because when invoking "dir" (without the cmd.exe) I had the same problem. I'm invoking it as: cmd.exe /C dir > std.out 2> std.err, but I am not using apr_files. I'm setting apr_procattr_io_set(pattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE) and setting the in/out/err to NULL is not working too. And I cannot change it to APR_PROGRAM_ENV because the application I am working with must run all kind of cmd programs, included cmd ;) Code example with no error control to shorten the mail: apr_procattr_t *pattr; apr_procattr_create(&pattr, mp)) != APR_SUCCESS); apr_procattr_io_set(pattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE); apr_procattr_cmdtype_set(pattr, APR_SHELLCMD_ENV); char * progname = "cmd.exe /C dir > std.out 2> std.err"; <------ command to execute int argc = 0; const char* argv[APP_MAX_ARGC]; apr_proc_t proc; argv[argc++] = progname; argv[argc++] = NULL; apr_proc_create(&proc, progname, (const char* const*)argv, NULL, (apr_procattr_t*)pattr, mp); M. Antònia
