Solved

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

Posted on 2008-10-29
4
361 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:Tobias
Tobias 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

Are You Headed to Black Hat USA 2017?

Getting ready for Black Hat next week? Kick things off with the WatchGuard Badge Challenge and test your puzzle and cipher skills. Do you have what it takes to earn our limited edition Firebox Badge? Get started today - https://crimsonthorn.net

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
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

623 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