Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: IPC::Run3 error

by Anonymous Monk
on Mar 10, 2011 at 08:07 UTC ( [id://892365]=note: print w/replies, xml ) Need Help??


in reply to Re: IPC::Run3 error
in thread IPC::Run3 error

Confirmed, gnuwin32 provides a dir.EXE, where as dir is a cmd.exe/command.com built-in
$ set IPCRUN3DEBUG=999 $ perl -MIPC::Run3 -e "run3 [qw! C:/PROGRA~1/gnuwin32/bin/dir.EXE /b / +s /a-d | cat !], undef,\*STDOUT,\*STDERR" run3(): running 'C:/PROGRA~1/gnuwin32/bin/dir.EXE' '/b' '/s' '/a-d' '| +' 'cat' run3(): redirecting stdout to filehandle 'GLOB(0x9ba4ec)' binmode STDOUT, :crlf run3(): redirecting stderr to filehandle 'GLOB(0x9ba52c)' binmode STDERR, :crlf C:/PROGRA~1/gnuwin32/bin/dir.EXE: /b: No such file or directory C:/PROGRA~1/gnuwin32/bin/dir.EXE: /s: No such file or directory C:/PROGRA~1/gnuwin32/bin/dir.EXE: /a-d: No such file or directory C:/PROGRA~1/gnuwin32/bin/dir.EXE: |: Invalid argument C:/PROGRA~1/gnuwin32/bin/dir.EXE: cat: No such file or directory run3(): $? is 512

Replies are listed 'Best First'.
Re^3: IPC::Run3 error
by ikegami (Patriarch) on Mar 10, 2011 at 08:18 UTC

    Ah, so you are using WinXP, it's just that you have a poorly named tool installed. Let me qualify my earlier post.


    Three problems.

    • You are using options that would be understood by Windows's dir command, which means you're not running Windows's dir command.

      The dir command is a builtin shell command. It can only be run from within a shell. Since you're not running a shell since you're using the multiple argument form of system, the right dir will never be found.

    • You're trying to run a shell command (a pipe). Since you're not running a shell since you're using the multiple argument form of system, that's not going to work.

    • You broke up the shell command into bits. How is the shell suppose to execute it?

    Solution:

    $cmd = 'dir /s/b/a-d | p4 -x - add';

    which is short for

    $cmd = ['cmd', '/c', 'dir /s/b/a-d | p4 -x - add'];

    Well, it's suppose to be. The latter doesn't work for some reason.

    Update: Removed extraneous quotes that caused the problem identified in the reply.

      I am not the OP.

      While system @$cmd will work, run3 will fail with

      '""""dir' is not recognized as an internal or external command, operable program or batch file.
      even if you hardcode a path to cmd.exe

        Sorry, the double quotes should be there. Typo. Fixed

        It still doesn't work, though. hum...

      Yeah, "hum." This is exactly what I was hoping to use run3 for, to run cmd.exe /u /c dir $filespec. It seems that, of the myriad ways that one might attempt to get a glob of Unicode filenames in Perl for Windows, approximately 0% of them work.

        It seems that, of the myriad ways that one might attempt to get a glob of Unicode filenames in Perl for Windows, approximately 0% of them work.

        I gave you code that works fine for me here. As I've said twice before, if you show us specifically what is wrong, we'll likely be able to help you fix it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-26 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found