Solved

How to exec Dos programs from perl

Posted on 1998-08-15
7
159 Views
Last Modified: 2010-03-05
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.
0
Comment
Question by:freak022398
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1203535
$result = `command`;
0
 

Author Comment

by:freak022398
ID: 1203536
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
 
LVL 84

Expert Comment

by:ozo
ID: 1203537
#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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Accepted Solution

by:
yoren earned 100 total points
ID: 1203538
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
 

Author Comment

by:freak022398
ID: 1203539
Great! Just what i needed to get that finished.
Thanks.
CYA. Martin.
0
 

Author Comment

by:freak022398
ID: 1203540
Ups, sorry for the delay, i thought i had graded you :(
At least i made it before you got auto graded.
CYA.

0
 
LVL 7

Expert Comment

by:yoren
ID: 1203541
You're welcome.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question