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
Solved

Is it possible and how to read 'echo' from Windows .bat file in Perl?

Posted on 2008-10-29
4
358 Views
Last Modified: 2012-05-05
There are a number of existing Windows .bat files in a project I've been given.  I don't want to have to rewrite these in another code or other, as they do the job and work great.  That said I'd like to create a Perl/Tk GUI to show what is happening, error messages, etc. I'm just starting Perl (know more in PHP), and Tk is a bit new to me, but I thought this GUI would be a great way to learn.  Here is the problem -- is it possible to have a Perl script get the 'echo' from a .bat file it initiates?  If so how?  I'm guessing this is after Perl calls the .bat through exec() or system().  Thanks in advance for the help.  While I'd like to do this in Perl, I suppose PHP is fine if someone can explain that as well.
0
Comment
Question by:Xerc
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 22832591
$read - `echo message`;
print "echo returned $read\n";
0
 
LVL 84

Expert Comment

by:ozo
ID: 22832597
$read = `echo message`;
print "echo returned $read\n";
0
 
LVL 10

Assisted Solution

by:MadShiva
MadShiva earned 150 total points
ID: 22832677
Hi !

For example :

#!/usr/local/bin/perl
my @result=`file.bat`;


Best Regards
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 350 total points
ID: 22833517
If you use backticks, you will get all of the output when the program finishes.  If this is good enough, that is the easiest way.

If you need the output as the .bat file generates it, use this:
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
If you have a multi-homed DNS setup in windows, you can have issues with connectivity to the server that hosts the DNS services (or even member servers of your domain if this same DNS server is a DC). This is because windows registers all of its IPs…
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…

829 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