Re: IPC::Run3 error
by ikegami (Patriarch) on Mar 10, 2011 at 08:00 UTC
|
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.
-
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, so how is the shell suppose to execute it?
Solution:
$cmd = 'find -type f | p4 -x - add';
| [reply] [d/l] |
|
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
| [reply] [d/l] |
|
$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. | [reply] [d/l] [select] |
|
|
|
|
|
|
|
Point of clarification:
I think the OP probably does not know that if you pass a scalar to system (or exec) then the shell is involved, but if you pass an array, then the shell get's bypassed, and the named command is run directly.
eg, This will pass the entire command string to the shell, which will in turn invoke find, and setup a pipe to send the output to p4.
system('find -type f | p4 -x - add')
You might try this, but it would not work, as the find command would receive all the other arguments, and would not know how to process anything after the pipe character.
system('find', '-type', 'f', '|', 'p4', '-x', '-', 'add')
Back to the OP's question. Under windows, the DIR command is a shell built in, so in order to invoke it, you must invoke the shell. There is not DIR.exe system file that could be invoked outside the shell.
| [reply] [d/l] [select] |
|
Except that there is, and it comes from gnuwin32, and its the cause of the error messages "dir: /b: No such file or directory
" ...
| [reply] |
|
Re: IPC::Run3 error
by Corion (Patriarch) on Mar 10, 2011 at 07:45 UTC
|
| [reply] |
|
| [reply] |
|
| [reply] |
|
|