----- Original Message -----
From: "LI NGOK LAM" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 14, 2003 6:05 AM
Subject: How to run a shell command but not waiting for the result ?
I've tried to use exec, system, and ``. And also with and without $| = 1;
but seems unable to do what I want.
What I want to do is suppose like this :
print "Start";
exec "notepad";
print "End";
but I found my results are :
If I can see "End", the notepad won't come,
If I can run the notepad, I can't see the End
until I close the notepad.
So what can I do to make it possible to run the notepad,
but then just leave it alone and go on with the rest of the
code ?
TIA
Hi -
If you have Perl 5.8, try threads:
use strict;
use warnings;
use threads;
my $thr = threads->new(\¬epad);
$thr->detach;
my $wait = 10;
while ($wait--) {
print "still alive $wait\n";
sleep 1;
}
print "ending\n";
sub notepad
{
system 'notepad';
}
see: perldoc perlthtut
(or as an html file under your html/lib/Pod
directory in your perl install tree.)
You first try won't work:
exec => NEVER returns (overlays you with
notepad);
system => puts you into a wait till notepad finishes.
Aloha => Beau;
== please visit ==
<http://beaucox.com> => main site
<http://howtos.beaucox.com> => howtos
<http://PPM.beaucox.com> => perl PPMs
<http://CPAN.beaucox.com> => CPAN
== thank you ==
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]