Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Executing perl program from another perl program and capturing the output

by Loops (Curate)
on Nov 25, 2014 at 04:30 UTC ( [id://1108310]=note: print w/replies, xml ) Need Help??


in reply to Re: Executing perl program from another perl program and capturing the output
in thread Executing perl program from another perl program and capturing the output

Hi BrowserUk,

It is my recollection that others have explicitly recommended the list form of system on Windows. Could you explain why it isn't helpful, so i'll not recommend it again in error?

  • Comment on Re^2: Executing perl program from another perl program and capturing the output

Replies are listed 'Best First'.
Re^3: Executing perl program from another perl program and capturing the output
by BrowserUk (Patriarch) on Nov 25, 2014 at 04:46 UTC
    ould you explain why it isn't helpful,

    Because CreateProcess() is the only way to spawn a new process on windows; and it only accepts a single string containing the runtime arguments.

    If you supply system with the list form of arguments, they just get concatenated together, before being passed as the second argument to CreateProcess().

    There is some attempt to apply intelligence to the concatenation process, but is does not handle paths with spaces (correctly):

    win32_spawnvp(int mode, const char *cmdname, const char *const *argv) { #ifdef USE_RTL_SPAWNVP return spawnvp(mode, cmdname, (char * const *)argv); #else dTHXa(NULL); int ret; void* env; char* dir; child_IO_table tbl; STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; DWORD create = 0; char *cmd; char *fullcmd = NULL; char *cname = (char *)cmdname; STRLEN clen = 0; if (cname) { clen = strlen(cname); /* if command name contains dquotes, must remove them */ ...

    About the dumbest thing it could do...


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Interesting. Thanks.

      I did see the following in the System docs:

      On Windows, only the system PROGRAM LIST syntax will reliably avoid using the shell; system LIST , even with more than one element, will fall back to the shell if the first spawn fails.

      And was thinking mistakenly that array flattening would suffice. It appears that if "USE_RTL_SPAWNVP" is defined, that horror show is avoided though yes? A quick look in the code didn't reveal if that's true or if it's even defined in the common case. But fwiw, I did see a note in the code recommending Win32::Process instead.

      Last time I checked it did handle paths with spaces correctly because all it does is add "" around the args

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1108310]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-18 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found