Greetings all!

It is me again doing things that just aren't meant for the GUI world.

I have created what I call a 'site index file' creation tool...basically it follows all the links at a site (or sites) and logs the URL, Title, and the content. This info gets written to a file which can then be searched on...sort of a hacked Content Index.

Anyways...doing traversals thru a small site (less than 100 pages; dynamic & static) works fine...however, when dealing with a larger site ( 100+ pages; dynamic & static), browsers tend to time out so I can never tell if the script finished or not since the response from the script never makes it back in time. Since I don't know how long the traversal will take, it's not a simple matter of just increasing the browser wait time (if that's possible).

Thinking back to the days when I started using Perl, I figured I would just try running this script from the DOS command line (yes, Virginia, I'm running XP). It works and the debugging information that I inserted displays on each pass. This is much better than outputting to the browser, which seems to wait until the script is completed before it shows me anything...

Only problem is all my debugging text is wrapped in HTML tags...great for browser display, but one big line of crap when output to the command line.

My question: Is there an easy check to tell if a script is being invoked from within a DOS shell vs from a browser. And if so, what is a good (one-liner) way to handle outputting text to each based on that? Something like: print ( if ( dos ) { "$debugtext\n\n"; } else { "<P>$debugtext</P>"; } )

As always - TIA

======================
Sean Shrum
http://www.shrum.net


In reply to Outputting to browser vs DOS...how can you tell? by S_Shrum

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.