Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Capture output but suppress it to screen

Posted on 2003-03-09
Medium Priority
Last Modified: 2008-03-04
Using perl with cygwin, i want to run an executable and capture its output but supress what is normally viewed in the console.

Say I run a dos box and type  "program.exe" and the screen outputs:

how are you

What I want is to run "perl.exe test.pl" with the following script

print "this is all that should show on screen"

and somehow supress the normal "hello how are you" output from showing on the screen.

Any ideas?

I'll raise points if this proves to be more complicated.
Question by:s_mack

Author Comment

ID: 8098983
nevermind... my question actually answered itself.

It seems that $output=`program.exe` DOES suppress the video output :P

So first person to put anything remotely intelligent, funny, or something other than "give me the points" gets the points.  Have a good one.
LVL 27

Accepted Solution

wilcoxon earned 80 total points
ID: 8099022
Yes.  `command` suppresses the output (more precisely, it puts it into $output).

Another option is:

open CMD, 'command |' or die "could not open pipe: $!";
while (<CMD>) {
    # do whatever you want with each line of output
close CMD;

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
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
Suggested Courses

564 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