Spawning external programs and running system commands from Windows

  • Thread starter Sol Linderstein
  • Start date
S

Sol Linderstein

Hi,

I'm trying to do something trivial with ActivePerl on an XP machine
with no success.

C:\PERL\TEST>perl
system("dir");
^D

I get no output. In Unix this command works fine, substituting 'ls'
for 'dir'. My perl install is working because other programs, that
don't spawn external programs produce the expected output to the
screen.

I'm basically trying to call an external program from perl in a
Windows environment and the system/dir example is the easiest one I
can think of and it doesn't produce any output. I've tried various
other things, namely backticking and piping which work in Unix.

What's the trick to spawning external programs from Perl in Windows?

Thanks,
SL
 
G

gnari

Sol Linderstein said:
Hi,

I'm trying to do something trivial with ActivePerl on an XP machine
with no success.

C:\PERL\TEST>perl
system("dir");
^D

should work.

as should:

C:\PERL\TEST>perl
print qx(dir);
^D

gnari
 
A

A. Sinan Unur

(e-mail address removed) (Sol Linderstein) wrote in
Hi,

I'm trying to do something trivial with ActivePerl on an XP machine
with no success.

C:\PERL\TEST>perl
system("dir");
^D

dir is a built-in command. The EOF character on for cmd and command
shells is ^Z (although ^D also seems to work on my machine with perl in
this case).

What you need is:

C:\Home\asu1> perl
system 'cmd /c dir *.txt';
^Z
Volume in drive C is HD
Volume Serial Number is F882-4E55

Directory of C:\Home\asu1

2004/05/12 09:12 PM 1,211 a.txt
2004/03/12 05:36 AM 4,278 ahsn.txt
2004/03/11 03:41 PM 103 asu1.sig.txt
2004/05/12 09:12 PM 1,131 b.txt
2003/08/20 02:04 PM 15,324 basicauth.txt

....
I'm basically trying to call an external program from perl in a
Windows environment and the system/dir example is the easiest one I
can think of and it doesn't produce any output. I've tried various
other things, namely backticking and piping which work in Unix.

What's the trick to spawning external programs from Perl in Windows?

There is no real trick but just to be sure, you might want to post a
short example showing your problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top