Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Windows 7: fork in perl script spawns new cmd window

by mpeppler (Vicar)
on Jan 25, 2013 at 09:26 UTC ( [id://1015296]=perlquestion: print w/replies, xml ) Need Help??

mpeppler has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I've just got a new Windows 7 laptop at work - running this little script:

open(IN, "svn info c:/path/to/file |"); @l = <IN>; foreach (@l) { print "$_"; }
opens a new cmd window which runs the svn info command instead of being able to read the output in the script.

This doesn't happen on other W7 machines around here, so I'm guessing this is a config issue somewhere - but my Windows admin know-how is essentially inexistent....

Any constructive suggestion (so "switch to linux" is not an option :-)) welcome!

Michael

Replies are listed 'Best First'.
Re: Windows 7: fork in perl script spawns new cmd window
by BrowserUk (Patriarch) on Jan 25, 2013 at 17:13 UTC

    Compare the settings of path, assoc .pl & ftype perl on the two machines.

    Therein (almost certainly) lies a difference; and explanation of the different behaviour.

    Also, you can probably dodge the issue by using the full path of the svn command.


    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.
Re: Windows 7: fork in perl script spawns new cmd window
by mpeppler (Vicar) on Jan 25, 2013 at 09:51 UTC
    OK - so adding "call" like so
    open(IN, "call svn info ... | ");
    fixes the problem - but I'd still like to understand why this is needed in this new environment, and isn't needed on other W7 machines or older XP machines around here.

    Michael

        It's from the exact same code, same build of perl 5.14, etc.
        The actual code uses IO::CaptureOutput, FWIW...

        Michael

Re: Windows 7: fork in perl script spawns new cmd window
by Anonymous Monk on Jan 25, 2013 at 09:30 UTC
    mine neither, try  use Win32 qw(SW_HIDE); Win32::SetChildShowWindow(SW_HIDE);
Re: Windows 7: fork in perl script spawns new cmd window
by Anonymous Monk on Jan 26, 2013 at 21:54 UTC
    Switching to Linux is a perfectly cromulent suggestion.

      Agreed. Using Linux embiggens even the smallest program.

Re: Windows 7: fork in perl script spawns new cmd window
by mpeppler (Vicar) on Jan 30, 2013 at 11:32 UTC
    So - here's the cause for the problem - in case someone else runs into something similar in the future.

    The svn.exe binary was included in a directory that has elevated execution rights associated through a policy. The perl binary is not in that same directory, so Win7's kernel refused to run the svn command in the same process space.

    Moving the svn binary out of this directory, or moving the perl tree into this directory resolves the problem.

    Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1015296]
Approved by Corion
Front-paged by MidLifeXis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found