check wildcards within a sub
am 08.08.2009 06:54:43 von Aclhk Aclhk
--===============0616285756==
Content-Type: multipart/alternative; boundary="0-644577623-1249707283=:8234"
--0-644577623-1249707283=:8234
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
I need to check image*.tiff if exists (just any one match is ok) within the=
following code. pls advise using glob or anything.
use Win32::Job;
my $job =3D Win32::Job->new;
$job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
 $ok =3D $job->watch( sub {
      return 1 if (-e "image*.tiff") || slee=
p (30);
  }
, 1);
=0A Yahoo!é¦æ¸¯æä¾ç¶²ä¸ =
å®å
¨æ»ç¥ï¼æä½ å¦ä=
½é²ç¯é»å®¢! è«åå¾=80 htt=
p://hk.promo.yahoo.com/security/ äºè§£æ´å¤!
--0-644577623-1249707283=:8234
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
|
top" style=3D"font: inherit;">I need to check image*.tiff if exists (just a=
ny one match is ok) within the following code. pls advise using glob or any=
thing.
use Win32::Job;
my $job =3D Win32::Job->new;
$job-&g=
t;spawn($Config{perlpath}, "perl c:\\test\\a.pl");
$ok =3D $job-&=
gt;watch( sub {
return 1 if (-e "im=
age*.tiff") || sleep (30);
}
, 1);
=
=0A
Yahoo!é¦æ¸¯æ=
ä¾ç¶²ä¸å®å
¨æ»ç ¥ï¼=8C=
æä½ å¦ä½é²ç¯é» 客!
href=3D"http://hk.promo.yahoo.com/security/">äºè§£æ=
´å¤
--0-644577623-1249707283=:8234--
--===============0616285756==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0616285756==--
Re: check wildcards within a sub
am 08.08.2009 17:30:15 von Aclhk Aclhk
--===============1923068274==
Content-Type: multipart/alternative; boundary="0-675397093-1249745415=:32427"
--0-675397093-1249745415=:32427
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
i want to kill spawned process and its child if image*.tiff exists or timeo=
ut.
c:\\test\\a.pl is to generate the tiff by print the acrobat reader to defau=
lt printer which creates the tif file.
i have tried the following without success.
use Win32::Job;
my $job =3D Win32::Job->new;
# Run for 10 seconds
print "start ......";
#$job->spawn($Config{perlpath}, "perl");
$job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
#$job->run(10);
 $ok =3D $job->watch( sub {
       return 1 if ((glob "image*.tiff"=
) || sleep (30));
  }
, 1);
If image*.tiff is changed to an file already existed, the spawn process is =
terminated very quickly. It could not detect image*.tiff if it is generated=
by a.pl (by printer driver). it times out after 30 secs.
I am a newbie to perl. pls kindly advise. if you know win32::process, pls a=
dvise code, too.
--- 2009å¹=B48æ=888æ=A5 ææå
ï¼M=
ichael Zeng 寫éï¹=95
å¯ä»¶äº=BA: Michael Zeng
主é¡: Re: check wildcards within a sub
æ¶ä»¶äº=BA: "Aclhk Aclhk"
æ¥æ: 2009å¹=B48æ=888æ=A5,ææ=E5=
,ä¸å12:50
if ( glob "image*.tiff" )  {
  Â=A0 .....=0A=
}
Â
 =0AOn Sat, Aug 8, 2009 at 12:54 PM, Aclhk Aclhk
> wrote:
=0AI need to check image*.tiff if exists (just any one match is=
ok) within the following code. pls advise using glob or anything.
use Win32::Job;
my $job =3D Win32::Job->new;
$job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
Â=A0 $ok =3D $job->watch( sub {
      return 1 if (-e "image*.tiff") || slee=
p (30);
  }
, 1);
Yahoo!é¦æ¸¯æä¾ç¶²ä ¸å®=89=
å
¨æ»ç¥ï¼æä½ å¦ ä½=E9=
²ç¯é»å®=A2!äºè§£æ=B 4å¤=9A
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
=0ATo unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
=0A
--=20
      Yours Sincerely
          Zeng H=
ong=20
Yahoo!é¦æ¸¯æä¾ç¶²ä=B8=
å®å
¨æ»ç¥ï¼æä ½ å¦=82=
ä½é²ç¯é»å®=A2! è«åå¾=80 =
http://hk.promo.yahoo.com/security/ äºè§£æ´å¤!
--0-675397093-1249745415=:32427
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
|
top" style=3D"font: inherit;">i want to kill spawned process and its child =
if image*.tiff exists or timeout.
c:\\test\\a.pl is to generate the tiff=
by print the acrobat reader to default printer which creates the tif file.=
i have tried the following without success.
use Win32::Job;<=
br>
my $job =3D Win32::Job->new;
# Run for 10 seconds
print=
"start ......";
#$job->spawn($Config{perlpath}, "perl");
$job->=
;spawn($Config{perlpath}, "perl c:\\test\\a.pl");
#$job->run(10);
=
$ok =3D $job->watch( sub {
&nb=
sp; return 1 if ((glob "image*.tiff") || sleep (30));
=
}
, 1);
If image*.tiff is changed to an file already exist=
ed, the spawn process is terminated very quickly. It could not detect image=
*.tiff if it is generated by a.pl (by printer driver). it times out after 3=
0
secs.
I am a newbie to perl. pls kindly advise. if you know win32::=
process, pls advise code, too.
--- 2009å¹=B48æ=888æ=
=A5 ææå
ï¼Michael Zeng <galaxy2004@gmai=
l.com> 寫éï¹=95
r-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><=
br>å¯ä»¶äº=BA: Michael Zeng <galaxy2004@gmail.com>
r>主é¡: Re: check wildcards within a sub
æ¶ä=BB=
¶äºº: "Aclhk Aclhk" <aclhkaclhk@ymail.com>
æ¥æ=9C=
=9F: 2009å¹=B48æ=888æ=A5,ææå
=A D,ä¸=
å12:50
if ( glob "im=
age*.tiff" ) {
=0A
.....
=0A
iv>}
=0A
=0A
=0A
gmail_quote">On Sat, Aug 8, 2009 at 12:54 PM, Aclhk Aclhk
><
_blank" href=3D"/mc/compose?to=3Daclhkaclhk@ymail.com">aclhkaclhk@ym ail.com=
> wrote:
=0A
der-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-=
left: 1ex;">=0A=0A<=
tbody>=0A=0AI need to check image*.tiff if exists (j=
ust any one match is ok) within the following code. pls advise using glob o=
r anything.
use Win32::Job; my $job =3D Win32::Job->new; $j=
ob->spawn($Config{perlpath}, "perl c:\\test\\a.pl"); =0A $ok =
=3D $job->watch( sub { return 1 =
if (-e "image*.tiff") || sleep (30); } , 1);
|
r>
=0A
=0AYahoo!é¦æ¸¯æ=
ä¾ç¶²ä¸å®å
¨æ»ç ¥ï¼=8C=
æä½ å¦ä½é²ç¯é» 客!
rel=3D"nofollow" target=3D"_blank" href=3D"http://hk.promo.yahoo.com/secur=
ity/">äºè§£æ´å¤
__________________=
_____________________________
ActivePerl mailing list
low" ymailto=3D"mailto:ActivePerl@listserv.ActiveState.com" target=3D"_blan=
k" href=3D"/mc/compose?to=3DActivePerl@listserv.ActiveState.com ">ActivePerl=
@listserv.ActiveState.com
=0ATo unsubscribe:
get=3D"_blank" href=3D"http://listserv.activestate.com/mailman/mysubs">http =
://listserv.ActiveState.com/mailman/mysubs
r clear=3D"all">=0A
--
=
Yours Sincerely
=
Zeng Hong
=0A
<=
br>=0A
Yahoo!é¦æ¸¯æ=
ä¾ç¶²ä¸å®å
¨æ»ç ¥ï¼=8C=
æä½ å¦ä½é²ç¯é» 客!
href=3D"http://hk.promo.yahoo.com/security/">äºè§£æ=
´å¤
--0-675397093-1249745415=:32427--
--===============1923068274==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1923068274==--
Re: check wildcards within a sub
am 08.08.2009 21:45:14 von Bill Luebkert
Aclhk Aclhk wrote:
> i want to kill spawned process and its child if image*.tiff exists or
> timeout.
> c:\\test\\a.pl is to generate the tiff by print the acrobat reader to
> default printer which creates the tif file.
>
> i have tried the following without success.
>
> use Win32::Job;
>
> my $job = Win32::Job->new;
>
> # Run for 10 seconds
> print "start ......";
> #$job->spawn($Config{perlpath}, "perl");
> $job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
> #$job->run(10);
>
>
> $ok = $job->watch( sub {
> return 1 if ((glob "image*.tiff") || sleep (30));
> }
> , 1);
>
> If image*.tiff is changed to an file already existed, the spawn process
> is terminated very quickly. It could not detect image*.tiff if it is
> generated by a.pl (by printer driver). it times out after 30 secs.
>
> I am a newbie to perl. pls kindly advise. if you know win32::process,
> pls advise code, too.
This seems to work (assuming the TIFF is generated in the current working
dir and the TIFF created is named something like 'image1.tiff':
use strict;
use warnings;
use Config;
use Win32::Job;
my $MAX_WAIT = 10; # seconds to wait for TIFF
my $job = Win32::Job->new;
$job->spawn($Config{perlpath}, 'perl a.pl');
my $start = time;
# assumes that a TIFF file is created in this (.) dir
print "watch for TIFF\n" if $debug;
$job->watch(
sub {
return 1 if glob ('image*.tiff');
my $diff = time - $start;
if ($diff > $MAX_WAIT) {
print "Timeout waiting for TIFF - exiting\n";
return 1;
}
return 0;
}, 1);
__END__
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: check wildcards within a sub
am 08.08.2009 21:55:19 von Bill Luebkert
Bill Luebkert wrote:
> Aclhk Aclhk wrote:
>> i want to kill spawned process and its child if image*.tiff exists or
>> timeout.
>> c:\\test\\a.pl is to generate the tiff by print the acrobat reader to
>> default printer which creates the tif file.
>>
>> i have tried the following without success.
>>
>> use Win32::Job;
>>
>> my $job = Win32::Job->new;
>>
>> # Run for 10 seconds
>> print "start ......";
>> #$job->spawn($Config{perlpath}, "perl");
>> $job->spawn($Config{perlpath}, "perl c:\\test\\a.pl");
>> #$job->run(10);
>>
>>
>> $ok = $job->watch( sub {
>> return 1 if ((glob "image*.tiff") || sleep (30));
>> }
>> , 1);
>>
>> If image*.tiff is changed to an file already existed, the spawn process
>> is terminated very quickly. It could not detect image*.tiff if it is
>> generated by a.pl (by printer driver). it times out after 30 secs.
>>
>> I am a newbie to perl. pls kindly advise. if you know win32::process,
>> pls advise code, too.
>
> This seems to work (assuming the TIFF is generated in the current working
> dir and the TIFF created is named something like 'image1.tiff':
>
> use strict;
> use warnings;
> use Config;
> use Win32::Job;
>
> my $MAX_WAIT = 10; # seconds to wait for TIFF
>
> my $job = Win32::Job->new;
> $job->spawn($Config{perlpath}, 'perl a.pl');
>
> my $start = time;
>
> # assumes that a TIFF file is created in this (.) dir
>
> print "watch for TIFF\n" if $debug;
> $job->watch(
> sub {
> return 1 if glob ('image*.tiff');
> my $diff = time - $start;
> if ($diff > $MAX_WAIT) {
> print "Timeout waiting for TIFF - exiting\n";
I left the kill part out - it would go here:
> return 1;
> }
> return 0;
> }, 1);
>
> __END__
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs