On one of our Windows XP machines, Perl system commands such as dir /b
generate an error message such as: /b: no such file or directory
. In other words, the switch is being interpreted as a filename.
This occurs whether I use backticks
, open()
or system()
. I even tried passing in the switch as a separate arg to system(). Naturally, I have confirmed that the call works correctly on the DOS command line or batch script.
Has anybody else encountered this?
You probably have Cygwin installed and dir.exe
is in your path which is not the cmd.exe
built-in but an alias to ls
.
C:\> which dir /usr/bin/dir C:\> c:\opt\cygwin\bin\dir.exe --version dir (GNU coreutils) 8.15 Packaged by Cygwin (8.15-1) … C:\> dir /b … C:\> perl -e "print `dir /b`" dir: cannot access /b: No such file or directory C:\> perl -e "print `cmd /c dir /b`" …