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

I found that

IPC::Run::run(['_testdir_/_test_.bat'])
fails on Windows, while
IPC::Run::run(['_testdir_\\_test_.bat'])
succeeds, using IPC::Run 0.80. I didn't find anything about path separator issues in the perldocs for IPC::Run. Does anyone know whether it is a bug, or a feature of IPC::Run to not accept Unix style path separators on Windows?

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re: IPC::Run on Windows, path separator
by Anonymous Monk on May 27, 2010 at 13:49 UTC
    Its invoking the shell, so I don't think its a bug, but I'm not sure what IPC::Run promises
    $ cat _testdir_\_test_.bat @echo %date% %time% $ cat runit.pl use IPC::Run; IPC::Run::run(['_testdir_/_test_.bat']); IPC::Run::run(['_testdir_\\_test_.bat']) ; $ perl runit.pl '_testdir_' is not recognized as an internal or external command, operable program or batch file. Thu 05/27/2010 6:47:20.93 $ _testdir_\_test_.bat Thu 05/27/2010 6:47:27.87 $ _testdir_/_test_.bat '_testdir_' is not recognized as an internal or external command, operable program or batch file.
      Its invoking the shell
      I would not expect that it does. From the perldocs:

      # Launch a sub process directly, no shell. Can't do redirectio +n # with this form, it's here to behave like system() with an # inverted result. $r = run "cat a b c" ;
      So this example explicitly says no shell.

      -- 
      Ronald Fischer <ynnor@mm.st>
        system calls the shell when it's documented not to in Windows. According to the documentation, perl -e"system('dir')" and perl -e"system('foo.bat')" should fail, yet both work. This might be documented in perlport.
        You're giving it a batch file, and only the shell runs batch files, so both the following lines work for me
        IPC::Run::run(['C:/perl/5.10.1/bin/MSWin32-x86-multi-thread/perl.EXE', + qw! -e die(666) !]) ; IPC::Run::run(['C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.EXE', + qw! -e die(666) !]) ;

      Interesting which cases work:

      C:\>c:/windows/explorer C:\>/windows/explorer C:\>windows/explorer 'windows' is not recognized as an internal or external command, operable program or batch file. C:\>

      - tye        

        Quotes almost always prevent the "/" from being treated as an option prefix.
        C:\>"windows/explorer" C:\>