Here's the situation, I have an executable that gets info about a database (I didn't write it). When run from the shell it prints out a dozen lines describing database. Example:

Version
Release date:
Creation date: 2:17:09 AM EST Nov 19, 2004
Modified date: 2:17:09 AM EST Nov 19, 2004
Type: Nucleotide
Alphabet: NCBI2na(1)
No. of sequences (letters): 37,316 (33,115,935)
Longest sequence: 1542
Edit Alphabet: WUStLna(1)
Max. edits: 41
Total edits: 2693

I want a line in the middle that gives sequence count (in this example 37,316). I can gather the output with backticks and extract this number with some regular expression acrobatics, and store it in a variable easy enough. The problem is that everytime I execute the database info command, its output is automatically printed to the screen.

I don't want to see this output, I just want to run the script, have it gather the other program's output behind the scenes, and print out just the number. Is this even possible? I have tried a variety of ways of running the external program such as backticks, opening a pipe and using exec(), doing a manual fork() then exec(), and plain old system(). They all seem to work the same. Do I need to somehow filter my own STDOUT?

Thanks,
Jared


In reply to capture STDOUT without printing to screen by k99ja04

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.