rovf has asked for the wisdom of the Perl Monks concerning the following question:
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 ...')"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Windows: system("type ...") vs. system("cmd /c type ...")
by syphilis (Archbishop) on Nov 17, 2008 at 11:50 UTC | |
by rovf (Priest) on Nov 17, 2008 at 12:34 UTC | |
|
Re: Windows: system("type ...") vs. system("cmd /c type ...")
by BrowserUk (Patriarch) on Nov 17, 2008 at 11:56 UTC | |
|
Re: Windows: system("type ...") vs. system("cmd /c type ...")
by massa (Hermit) on Nov 17, 2008 at 11:40 UTC | |
by rovf (Priest) on Nov 17, 2008 at 12:31 UTC | |
|
Re: Windows: system("type ...") vs. system("cmd /c type ...")
by xiaoyafeng (Deacon) on Nov 18, 2008 at 07:36 UTC | |
by BrowserUk (Patriarch) on Nov 18, 2008 at 07:59 UTC |