check wildcards within a sub

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=0A r>
I 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);

=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