Command 'dir' not found in C:\MinGW\bin, C:\Python27,..... when use IPC::Run

I came across this error when I run follow code on windows.
and if changed the command `dir` to `ipconfig`, it's ok.
I guess it because dir is a cmd internal command but ipconfig isn't.

Can anybody explain it for me.

Thanks

code:

use strict;
use IPC::Run qw(run timeout);

my [at] cmd = qw(dir);
my ($in, $out, $error);
open $in, "<in.txt";
open $out, ">out.txt";
open $error, ">error.txt";

run \ [at] cmd, $in, $out, $error, timeout(10) or die "error: $?";

close $in;
close $out;
close $error;


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
hsin [ Do, 21 Juli 2011 12:50 ] [ ID #2062413 ]

Re: Command 'dir' not found in C:\MinGW\bin, C:\Python27,..... whenuse IPC::Run

Hi hsin,

On Thu, 21 Jul 2011 03:50:36 -0700 (PDT)
hsin <wangwangxin [at] gmail.com> wrote:

> I came across this error when I run follow code on windows.
> and if changed the command `dir` to `ipconfig`, it's ok.
> I guess it because dir is a cmd internal command but ipconfig isn't.

I think that's the case. You shouldn't depend on "dir" from within Perl
anyway because Perl has native and portable routines and modules to query the
file system:

http://perl-begin.org/uses/sys-admin/

Regards,

Shlomi Fish

>
> Can anybody explain it for me.
>
> Thanks
>
> code:
>
> use strict;
> use IPC::Run qw(run timeout);
>
> my [at] cmd = qw(dir);
> my ($in, $out, $error);
> open $in, "<in.txt";
> open $out, ">out.txt";
> open $error, ">error.txt";
>
> run \ [at] cmd, $in, $out, $error, timeout(10) or die "error: $?";
>
> close $in;
> close $out;
> close $error;
>
>



--
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

Chuck Norris is a real programmer. He writes programs by implementing the most
optimised machines for them using real atoms.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Shlomi Fish [ Do, 21 Juli 2011 15:10 ] [ ID #2062441 ]
Perl » gmane.comp.lang.perl.beginners » Command 'dir' not found in C:\MinGW\bin, C:\Python27,..... when use IPC::Run

Vorheriges Thema: Re: parsing script duplication of lines issue, please advise
Nächstes Thema: RE: url checker load average opensource s/w