I found that with ActiveState Perl 5.10 on Windows, I can do
a system("dir myfile"), but I can't do a system("type myfile"). Could someone kindly explain me why? Here the
example code to demonstrate this problem:
# This is program omoshiroi.pl
use strict;
use warnings;
sub systemx($) {
my $cmd=shift;
print "EXECUTING: $cmd\n";
system $cmd;
}
my $tmpfh=$ARGV[0];
systemx("dir $tmpfh");
systemx("type $tmpfh");
systemx("cmd /c type $tmpfh");
The only purpose of
systemx is to show the command being executed. Now create some text file, say:
abc.bat, and execute it like this:
omoshiroi.pl abc.bat
On my system, the output looks like this:
H:\tmp>omoshiroi1.pl abc.bat
EXECUTING: dir abc.bat
Datenträger in Laufwerk H: ist CIFS.HOMEDIR
Datenträgernummer: 0000-0000
Verzeichnis von H:\tmp
15.05.2008 14:00 65 abc.bat
1 Datei(en) 65 Bytes
0 Verzeichnis(se), 1.239.298.048 Bytes frei
EXECUTING: type abc.bat
abc.bat not found
EXECUTING: cmd /c type abc.bat
pwd
. $HOME
.bash_profile
echo $PATH
sview fischron_exp_dv ls -a
As you can see,
dir can find the file,
cmd /c type
can find the file, but
type can't find it. Strange, isn't it?
--
Ronald Fischer <ynnor@mm.st>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.