Solved

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

Posted on 2008-10-29
4
357 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create SPF records 3 38
Hiding a site page from being searchable 3 61
Mimecast Bounce 3 48
SharePoint 2013 Alternate Access Mappings not working 2 54
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
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…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now