Solved

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

Posted on 2008-10-29
4
359 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
[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
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

740 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