How to exec Dos programs from perl

How does i call a msdos command from perl, and then wait for the command to end and the result to return to my perl program?
CYA. Martin.
freak022398Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
yorenConnect With a Mentor Commented:
Actually you can get both types of result:

$command = "del *.*";

open(COMMAND,"$command|") or die "Error executing $command: $!";
$output = join("",<COMMAND>);
close(COMMAND); # Wait for the command to finish

$exitcode = ($? >> 8); # Exit code of zero usually means success, 1 usually failure

0
 
ozoCommented:
$result = `command`;
0
 
freak022398Author Commented:
I just got the script to start the exe file using the
system ("command"); function.
But how do i get the results from the program in the perl script?

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ozoCommented:
#If by result, you mean the exit code,
$exitcode=system ("command");
#if by result, you mean the stdout:
$output=`command`;
#or
$output=qx"command";
#or
open(COMMAND,'command|');
$output = join'',<COMMAND>;
0
 
freak022398Author Commented:
Great! Just what i needed to get that finished.
Thanks.
CYA. Martin.
0
 
freak022398Author Commented:
Ups, sorry for the delay, i thought i had graded you :(
At least i made it before you got auto graded.
CYA.

0
 
yorenCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.