Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to exec Dos programs from perl

Posted on 1998-08-15
7
Medium Priority
?
161 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Accepted Solution

by:
yoren earned 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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

636 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