I found that on Windows (using ActiveState Perl 5.10) the command
result in a "File not found" message, whileperl -e "system('type myfile.txt')"
- the latter being the Windows port of the Gnu utilities - work as expected.perl -e "system('cmd /c type myfile.txt')" perl -e "system('cat myfile.txt')"
My first explanation was that cmd.exe is bypassed in the first case, and since type is an internal command, it can't be executed that way. This explanation, however, can't be correct, because Windows doesn't complain about 'type' not being found, it complains about myfile.txt. Also,
works fine, although dir is an internal command as well. Does anybody know why type is so special? I'm asking this out of curiosity, because in a real application, I would not shell out to type a file, but do it directly from Perl.perl -e "system('dir ...')"
In reply to Windows: system("type ...") vs. system("cmd /c type ...") by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |