After reading BrowserUK's last post on this, I've got one really crazy "out of the box" idea. I'm sure that there will be some who will consider this idea to be ugly and I could not disagree. Also, it's not a purely Perl solution.
Ok, here's the crazy (stupid???) idea of mine. First, it sounds like your running on Windows, which is the basis for my idea. One good source of line command utilities for the Windows environment is the Sysinternals suite, which is available for free from Microsoft. In this case, you'll be interested in the pskill tool, which allows you to kill a process by name from a line command (i.e. the equivalent of killing a process via task manager).
Here's the outline of what I'd try if I were in your place.
- Download the pskill tool. (The first time you run it, there will be a pop window about the EULA. That just happens on the first time you run it.)
- In your Perl script, modify it to use threads.
- Start one thread to launch your program.exe such that STDERR is piped to STDOUT and STDOUT is piped to a file. From a command prompt, the syntax of that piping would be something like program.exe >log.txt 2>&1. (Can't remember the exact syntax.)
- Start another thread that does uses sleep to wait X amount of time and the launch the pskill command to kill your program.exe (pskill program.exe).
It may be an ugly solution, but it just might work. Also, it won't directly capture the output of your program.exe in Perl. Perhaps someone else might have a better Perl-based idea, but this is the best idea that I could come up with based on my knowledge of Perl.
Good luck with your efforts.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.