Re^2: IPC::Run3 error
by Anonymous Monk on Mar 10, 2011 at 08:07 UTC
|
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] |
|
|
'""""dir' is not recognized as an internal or external command,
operable program or batch file.
even if you hardcode a path to cmd.exe | [reply] [d/l] |
|
|
|
|
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.
| [reply] |
|
|
|
|
|
|
|
Re^2: IPC::Run3 error
by chrestomanci (Priest) on Mar 10, 2011 at 13:40 UTC
|
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] |
|
|
The garbage he's giving to it (e.g. "/b") is the cause of the error messages.
If he invokes dir through a shell, the shell builtin would be invoked, and it takes "/b".
If he invokes dir dircetly, the gnuwin32 executable would be invoked, and it doesn't take "/b".
| [reply] [d/l] [select] |