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

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.
XercAsked:
Who is Participating?
 
Adam314Connect With a Mentor Commented:
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
 
ozoCommented:
$read - `echo message`;
print "echo returned $read\n";
0
 
ozoCommented:
$read = `echo message`;
print "echo returned $read\n";
0
 
TobiasConnect With a Mentor Commented:
Hi !

For example :

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


Best Regards
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.