[22682] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4903 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 28 06:06:05 2003

Date: Mon, 28 Apr 2003 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Apr 2003     Volume: 10 Number: 4903

Today's topics:
        Can  Internet Explorer be run from inside perl ? <jhiggins@netsatx.net>
    Re: Can Perl enter data into web page form fields?  "Fa <SeeMessageBody@nospam.com>
    Re: Can Perl enter data into web page form fields?  "Fa (Bryan Castillo)
    Re: Can Perl enter data into web page form fields?  "Fa <REMOVEsdnCAPS@comcast.net>
    Re: compiling c pgms as part of perl mods for windows - (R Solberg)
    Re: compiling c pgms as part of perl mods for windows - <kalinabears@hdc.com.au>
        Compiling Perl 5.8 on SuSe Linux 8.0 <sigbert@wiwi.hu-berlin.de>
    Re: Curses and perl5.8 <tassilo.parseval@rwth-aachen.de>
    Re: Curses and perl5.8 <REMOVEsdnCAPS@comcast.net>
    Re: Get PID from process started by "system" - how? <anthony@movielink.net.au>
    Re: Get PID from process started by "system" - how? <goldbb2@earthlink.net>
    Re: Get PID from process started by "system" - how? <anthony@movielink.net.au>
    Re: Get PID from process started by "system" - how? <denshimeiru-sapmctacher@durchnull.ath.cx>
    Re: Get PID from process started by "system" - how? <anthony@movielink.net.au>
        How to compress and uncompress the files using the perl (Vinod. K)
    Re: How to compress and uncompress the files using the  (Anno Siegel)
    Re: Netscape Enterprise 3.5 and flock <Andrew.McGregor@amtrak.co.uk>
    Re: perl hash - help request (shree)
    Re: perl hash - help request (Anno Siegel)
        RE: Receive Authorize.NET AIM response from SSL port 44 <Scarr@bunny.com>
    Re: Regex greediness question (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 27 Apr 2003 22:24:13 -0400
From: "jhiggins" <jhiggins@netsatx.net>
Subject: Can  Internet Explorer be run from inside perl ?
Message-Id: <3eac8fb5$1@news.netsatx.net>

Can IE be run from inside perl.  I want to create a program that will scan
my MRTG images on a timed basis.




------------------------------

Date: Mon, 28 Apr 2003 01:33:04 GMT
From: "John" <SeeMessageBody@nospam.com>
Subject: Re: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <kx%qa.44906$4P1.4163819@newsread2.prod.itd.earthlink.net>


"Michael Budash" wrote:
John: > > Anybody know a way to get Perl to enter data into fields on a web
page form?
>
> elaborate, pls. your own form, or a remote site's form?
>

OOH!  Did I ever do a poor job of posting that one --sorry!  Tina correctly
divined what I meant, which is:  I want to automate data entry on the client
side.  The "WWW::Mechanize::Shell" package sounds tantalizing but I did not
see it for ActivePerl, which is a surprise because I see it on cpan.org.
(I'm using Windows.)

I want to run a script and have that script enter stuff into a web browser
and press enter, just as if I were there doing it.  Trying to automate data
entry.  It would have to be a slick module to find fields on a web page.

All of the Perl modules for I've found for the web are for the server side
(CGI, etc.).




------------------------------

Date: 28 Apr 2003 01:13:26 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <1bff1830.0304280013.60192650@posting.google.com>

"John" <SeeMessageBody@nospam.com> wrote in message news:

<snip>

> (I'm using Windows.)
> 
> I want to run a script and have that script enter stuff into a web browser
> and press enter, just as if I were there doing it.  Trying to automate data
> entry.  It would have to be a slick module to find fields on a web page.
> 
> All of the Perl modules for I've found for the web are for the server side
> (CGI, etc.).

If you really want to send keys to a web browser you are in for
trouble.  Its a pain trying to automate gui's that pop-up various
dialogs differently depending on the browser settings. (but you can do
it).

Have you looked at trying to use LWP::UserAgent to send GET/POST data
(this can be done with HTTP::Request::Common.  If you need to extract
form data and possible variables for your next POST, use one of the
HTML parsers like HTML::TokeParser.

However, if you still need to use a gui web browser and send keys to
it on Windows, you can do it with Win32::OLE.  You can start Internet
Explorer and get a handle to it.  From that handle you can navigate to
various URL's.  You can also access the Document Object Model of the
html document
To send the keys you need to create a WScript.Shell activeX object. 
You can use the SendKeys method to send key strokes.

Here is an example of using Win32::OLE to submit a form through
sending key strokes and through accessing the DOM.

use strict;
use warnings;
use Win32::OLE;

sub ie_goto {
  my ($ie, $url) = @_;
  $ie->Navigate2($url);     # go to an address (async)
  wait_for_completion($ie); # wait until page is loaded

# using a busy-wait since I couldn't get callback events to work for
IE
sub wait_for_completion {
  my $ie = shift;
  while($ie->{Busy}) {
    select undef, undef, undef, 0.25; # sleep 1/4 second
    print ".";
  }
  print "\n";
}

$|=1;

# used to send keystrokes
my $shell = Win32::OLE->new('WScript.Shell');

# start IE
my $ie = Win32::OLE->new('InternetExplorer.Application');
$ie->{Visible} = 1;

# go to a page with a form
ie_goto($ie, 'http://localhost/finances/adhoc.php');

sleep 2; # didn't seem to work w/o this hmmmmm?

# Send keystrokes to submit a form
$shell->SendKeys("{TAB}{TAB}{TAB}");
$shell->SendKeys("select * from check_book where cleared != 1");
$shell->SendKeys("{TAB}{TAB}{ENTER}");
wait_for_completion($ie);

print "Press Enter to try method 2\n";
<STDIN>;

# use the Document Object Model to submit a form
# access the first form in the page (javascript document.forms[0])
# there is a textarea field named 'sql'
$ie->{Document}{forms}->Item(0)->{sql}{value} =
  "select category, count(*), sum(amount) from check_book ".
  "where subdate(tran_date, interval 30 day) ".
  "group by category ".
  "order by tran_date desc, tran_type, payee";

# submit the form
$ie->{Document}{forms}->Item(0)->Submit();
wait_for_completion($ie);

# read and save the html - 
# you might use HTML::(Toke|Pull)?Parser here
open(HTML, ">data.html") || die "Error: can't open data.html - $!";
print HTML $ie->{Document}{documentElement}{innerHTML};
close(HTML);

print "Press Enter to exit\n";
<STDIN>;
$ie->Quit();


------------------------------

Date: Mon, 28 Apr 2003 04:57:01 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <Xns936B3C795C492sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"John" <SeeMessageBody@nospam.com> wrote in
news:kx%qa.44906$4P1.4163819@newsread2.prod.itd.earthlink.net: 

> ...but I did not see it for ActivePerl, which is a surprise
> because I see it on cpan.org. (I'm using Windows.)

Shouldn't be that much of a surprise, since not everything on CPAN is
available for ActiveState users.  Which is one reason why I prefer
the cygwin perl for windows.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+rPrUY96i4h5M0egRAqY3AKC2A8xw5ei3WL3NneDggPjpcqNrxACdHbrc
iCRjDpzPBTleugAM+ztrI0g=
=8iLP
-----END PGP SIGNATURE-----


------------------------------

Date: 27 Apr 2003 21:57:19 -0700
From: flateyjarbok@yahoo.com (R Solberg)
Subject: Re: compiling c pgms as part of perl mods for windows -- newbie
Message-Id: <386cc483.0304272057.131c1752@posting.google.com>

> 
> Hi,
> 
> You would normally build this module by running 'perl Makefile.PL', 'make
> test' and 'make install'.
> Sounds to me that you're not following that procedure - apologies if I'm
> wrong :-)

On your suggestion, I ran perl Makefile.pl and it looks like this ran successfully.

> 
> Check the output of 'perl -V:make'. You'll want to use whatever it reports
> instead of "make".

perl -V:make yields the following:

make='nmake';

But then I tried nmake and I get "Bad command or file line".
Did a search for nmake on the c: drive and no where to be found.
make instead of nmake does not work, either.

Any suggestions?  I have perl 5.8 installed on windows.



> 
> Hth.
> 
> Cheers,
> Rob


------------------------------

Date: Mon, 28 Apr 2003 17:38:55 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: compiling c pgms as part of perl mods for windows -- newbie
Message-Id: <3eacdb87$0$21276@echo-01.iinet.net.au>


"R Solberg" <flateyjarbok@yahoo.com> wrote in message
news:386cc483.0304272057.131c1752@posting.google.com...
> >
> > Hi,
> >
> > You would normally build this module by running 'perl Makefile.PL',
'make
> > test' and 'make install'.
> > Sounds to me that you're not following that procedure - apologies if I'm
> > wrong :-)
>
> On your suggestion, I ran perl Makefile.pl and it looks like this ran
successfully.
>
> >
> > Check the output of 'perl -V:make'. You'll want to use whatever it
reports
> > instead of "make".
>
> perl -V:make yields the following:
>
> make='nmake';
>
> But then I tried nmake and I get "Bad command or file line".
> Did a search for nmake on the c: drive and no where to be found.
> make instead of nmake does not work, either.
>
> Any suggestions?  I have perl 5.8 installed on windows.
>
>

You can download nmake from the Microsoft website - but, unfortunately, I
fear you'll also need the msvc++ compiler - which is not available for free
from anywhere.

In the interest of providing you with a working Math::CDF, I'll email you
the files you need (assuming you've provided your actual email address). If
they don't turn up, let me know.

Cheers,
Rob




------------------------------

Date: 28 Apr 2003 07:35:25 GMT
From: Sigbert Klinke <sigbert@wiwi.hu-berlin.de>
Subject: Compiling Perl 5.8 on SuSe Linux 8.0
Message-Id: <Xns936B618F45C9Csigbertwiwihuberlind@141.20.1.135>

Hi,

I tried myself to compile perl5.8.0 for a Suse Linux 8.0 system. Compiling 
seems to work well, but make test complains often about

# Can't load '../lib/auto/File/Glob/Glob.so' for module File::Glob: 
undefined symbol: PL_sv_undef at ../lib/XSLoader.pm line 83.
#  at ../lib/File/Glob.pm line 96
# Compilation failed in require at - line 23.
# BEGIN failed--compilation aborted at - line 23.
# STATUS: 65280
# Failed at ./test.pl line 567
# FAILED at test 91


Any idea what goes wrong ? My config file is available under 
http://ise.wiwi.hu-berlin.de/~sigbert/temp/perl/config.sh. I tried other 
choices than 'linux' during configuration, e.g. 'i386'. But then the config 
program complains that gdbm is missing.
 
Thanks a lot in advance

    	Sigbert


------------------------------

Date: 28 Apr 2003 09:32:45 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Curses and perl5.8
Message-Id: <b8isft$hv1$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Benjamin Goldberg:

> "Tassilo v. Parseval" wrote:

>> That looks like a 32bit versus 64bit issue. Your perl appears to be
>> compiled with -Duse64bitint. Line 148 is
>> 
>>     if (sv_isa(sv, "Curses::Field")) { return (FIELD*)SvIV((SV*)SvRV(sv)); }
>> 
>> so the IV returned by SvIV is larger than a pointer to FIELD (that is
>> what the warning implies).
>> 
>> That's the diagnostic part. I have no fix. You should send a message to
>> the author of the module and ask him whether he's aware of any such
>> problem.
> 
> How about:
> 
>    if (sv_isa(sv, "Curses::Field")) {
>       return INT2PTR( FIELD*, SvIV((SV*)SvRV(sv)) );
>    }
> 
> Instead of a simple cast?

Indeed, INT2PTR is a macro defined in perl.h. I never heard of it
before. I wonder why some of these vital macros are not documented in
perlapi.pod. Programmers would really use them once they know they
exist. ;-)

>> This is not clear to me at all. The line in question looks fine to me:
>> 
>>     if (Perl_sv_isa(sv, "Curses::Window")) {
>> 
>> sv is a proper 'SV*' and the second argument is a 'const char*' as
>> described by perlapi.pod.
> 
> That should be either:
> 
>       if (Perl_sv_isa(aTHX_ sv, "Curses::Window")) {
> 
> Or:
> 
>       if (sv_isa(sv, "Curses::Window")) {
> 
> You shouldn't use the Perl_ version without having aTHX_ in front of the
> first argument.

Thread context, I see. I never ever had a perl with any of the two
thread-flavors compiled in so I got too used to the idea that aTHX_ and
pTHX_ were empty #defines for me. 

Thanks, Benjamin. That explains nicely why the module in question
compiled fine for me and not for the OP. This will also help me in those
cases when one of my XS works does not compile on a certain machine. I
remember having problems with compiling them under Windows. ActiveState
at least has the multiplicity thing in their binaries so there might be
the cause.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Mon, 28 Apr 2003 04:54:07 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Curses and perl5.8
Message-Id: <Xns936B3BFB96286sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in
news:b8isft$hv1$1@nets3.rz.RWTH-Aachen.DE: 

> Also sprach Benjamin Goldberg:
> 
>> That should be either:
>> 
>>       if (Perl_sv_isa(aTHX_ sv, "Curses::Window")) {
>> 
>> Or:
>> 
>>       if (sv_isa(sv, "Curses::Window")) {
>> 
>> You shouldn't use the Perl_ version without having aTHX_ in front
of
>> the first argument.
> 
> Thread context, I see. I never ever had a perl with any of the two
> thread-flavors compiled in so I got too used to the idea that
aTHX_
> and pTHX_ were empty #defines for me. 

So what does that mean for people who have this compilation error?

If they have threading enabled, they should manually change the line
in error to the first line above; if they don't, they should manually
change it to the second above?

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+rPoiY96i4h5M0egRAhDuAJ4vdlB+KhORMqrLCq4pvDwwFrfEWgCg1heD
feo4aL9rGLL+lCHU+gprDf4=
=wUbE
-----END PGP SIGNATURE-----


------------------------------

Date: Mon, 28 Apr 2003 11:54:28 +1000
From: "Tony" <anthony@movielink.net.au>
Subject: Re: Get PID from process started by "system" - how?
Message-Id: <pan.2003.04.28.01.54.27.352121@movielink.net.au>

On Sun, 27 Apr 2003 11:11:46 +0000, Rudolf Polzer wrote:

> Scripsit ille aut illa »Tony« <anthony_w@no_spam.bigpond.com>:

>> I have searched high and low (Google) and can
>> not seem to find a way of getting the PID of
[...]
>> system "/usr/bin/some_program"
>> 
>> I need to get the PID of "some_program" when it
>> starts and store it for later use. How?
[...]
 
> Nobody does. When system returns, your /usr/bin/some_program already
> has exited, and its PID doesn't interest anyone.

In my case it does:-)

The reason for this is that I will use 'fork" to start a second
process (perl) that in turn will start processing a list of
files.  I need to be able to find and kill the second process
when (Or if) a specific event occures in the main perl program.

I did not make this very clear in my post- sorry...

> So you're probably calling a daemon which forks on startup. You could
> check if it writes a PID file (normally in /var/run) and if not, make it

Thanks again

Tony

(Posting from work)

 
> sub ForkAndExec(@)
> {
>   if (my $pid = fork())
>   {
>     return $pid;
>   }
>   else
>   {
>     exec { $_->[0] } @_
>       or exit 0xF001;
>   }
> }
> 
> my $pid = ForkAndExec sleep => 3;
> print "$pid\n";
> my $res = wait;
> print "$res exited with code $?\n";
> 
> outputs:
> 
> 19560
> 19560 exited with code 0

-- 
--------------------------------------------------------------
To reply directly send to: anthony AT movielink DOT net DOT au
Replace AT and DOT with @ and . and mail will get through.
Any spammers will be persued until they get booted off the net



------------------------------

Date: Sun, 27 Apr 2003 23:08:43 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Get PID from process started by "system" - how?
Message-Id: <3EAC9B3B.1E159093@earthlink.net>

Tony wrote:
> 
> On Sun, 27 Apr 2003 11:11:46 +0000, Rudolf Polzer wrote:
> 
> > Scripsit ille aut illa »Tony« <anthony_w@no_spam.bigpond.com>:
> 
> >> I have searched high and low (Google) and can
> >> not seem to find a way of getting the PID of
> [...]
> >> system "/usr/bin/some_program"
> >>
> >> I need to get the PID of "some_program" when it
> >> starts and store it for later use. How?
> [...]
> 
> > Nobody does. When system returns, your /usr/bin/some_program already
> > has exited, and its PID doesn't interest anyone.
> 
> In my case it does:-)
> 
> The reason for this is that I will use 'fork" to start a second
> process (perl) that in turn will start processing a list of
> files.

The process that system() creates, is the one which you say will use
'fork' ... and the "second" (actually third) process which will be doing
the processing of the list of files is the *grandchild* of the current
process.  The intermediate process, the one which was started by
system(), and which is the parent of the process doing the processing,
will have exited by the time system() returns... just like Mr. Polzer
said.  Your main perl script has no way of knowing the PID of it's
grandchild, unless it, or the intermedite process, sends it to your main
perl script via some form of IPC.

> I need to be able to find and kill the second process
> when (Or if) a specific event occures in the main perl program.

No, you need to find and kill the *third* process, due to that extra
forking.  And unless the *second* process gets modified to tell you,
you'll never know.

If you could show us more of what's going on (what's that third process
doing?), we could help you more, and show you a better, more perlish,
way of doing it.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


------------------------------

Date: Mon, 28 Apr 2003 18:17:06 +1000
From: "Tony" <anthony@movielink.net.au>
Subject: Re: Get PID from process started by "system" - how?
Message-Id: <pan.2003.04.28.08.17.05.256605@movielink.net.au>

On Sun, 27 Apr 2003 23:08:43 -0400, Benjamin Goldberg wrote:

> Tony wrote:
>> 
>> On Sun, 27 Apr 2003 11:11:46 +0000, Rudolf Polzer wrote:
 
>> >> I have searched high and low (Google) and can
>> >> not seem to find a way of getting the PID of
[...SNIP...]

>> In my case it does:-)
>> 
>> The reason for this is that I will use 'fork" to start a second
>> process (perl) that in turn will start processing a list of
>> files.
> 
> The process that system() creates, is the one which you say will use
> 'fork' ... and the "second" (actually third) process which will be doing
> the processing of the list of files is the *grandchild* of the current
> process.  The intermediate process, the one which was started by
> system(), and which is the parent of the process doing the processing,
> will have exited by the time system() returns... just like Mr. Polzer
> said.  Your main perl script has no way of knowing the PID of it's
> grandchild, unless it, or the intermedite process, sends it to your main
> perl script via some form of IPC.
> 
>> I need to be able to find and kill the second process
>> when (Or if) a specific event occures in the main perl program.
> 
> No, you need to find and kill the *third* process, due to that extra
> forking.  And unless the *second* process gets modified to tell you,
> you'll never know.
> 
> If you could show us more of what's going on (what's that third process
> doing?), we could help you more, and show you a better, more perlish,
> way of doing it.


I will try and explain in more detail.
--------------------------------------

I run a "main" perl program.  Its task is to
keep reading a file which contains a "program"
schedule like this:

MON 12:00 0 (some_file1 1, some_file2 1, some_file3 5)
MON 15:00 0 (other_file1 1, other_file2 1, other_file3 5)
MON 15:30 1 (new_file1 1, new_file2 1, new_file3 5)
etc...

I compare the first 2 fields (day,time) with the system time
(perl's localtime) and on a DAY,TIME match start playing
the files listed after that specific DAY,TIME to a DEVICE no.
designated by the 3rd field.

The single digit after each file designates the number of times
to play the file to the specified DEVICE.

When the next "time match" comes up the program must stop the
playback (Kill the "play" program) if it is running (It will
be most of the time) and start a new playback process with the
next list of files.  I will check to see if it is on the same
DEVICE first before "killing".  I will also store the PID of
the fork or "child" ID and kill that after killing the "play"
program.

My problem is obvious when you know that the files are "played"
by an external program.  The play program returns 0 when the
"play" has completed and perl continues.

Unfortuneatly perl will "wait" until the external "play" program
completes before continuing.  That means that any "time match"
will not happen if the "play" program is processing a file.

My idea was to pick up the PID from the "play" program, store that
in a PID file together with the DEVICE number and let the main perl
program continue checking for matches in the "program" schedule.

This should be possible by using "fork" to run a seperate perl
sub-routine that does the playing of the files as trigered by
the previous event.

An other way would be to check the status of the "/dev/output"
(The device file used) to see if it is free, if not the "play"
program is running.

In any event a "fork" or other mechanism would be required to
enable the main program to continue.

Hope this makes it clearer...

Tony



-- 
--------------------------------------------------------------
To reply directly send to: anthony AT movielink DOT net DOT au
Replace AT and DOT with @ and . and mail will get through.
Any spammers will be persued until they get booted off the net



------------------------------

Date: 28 Apr 2003 08:39:37 GMT
From: Rudolf Polzer <denshimeiru-sapmctacher@durchnull.ath.cx>
Subject: Re: Get PID from process started by "system" - how?
Message-Id: <slrnbapq68.et7.denshimeiru-sapmctacher@message-id.durchnull.ath.cx>

Scripsit ille aut illa »Tony« <anthony@movielink.net.au>:
> I will try and explain in more detail.
> --------------------------------------
> 
> I run a "main" perl program.  Its task is to
> keep reading a file which contains a "program"
> schedule like this:
> 
> MON 12:00 0 (some_file1 1, some_file2 1, some_file3 5)
> MON 15:00 0 (other_file1 1, other_file2 1, other_file3 5)
> MON 15:30 1 (new_file1 1, new_file2 1, new_file3 5)
> etc...
[...]
> Unfortuneatly perl will "wait" until the external "play" program
> completes before continuing.  That means that any "time match"
> will not happen if the "play" program is processing a file.
> 
> My idea was to pick up the PID from the "play" program, store that
> in a PID file together with the DEVICE number and let the main perl
> program continue checking for matches in the "program" schedule.

You use the same 'play' program I know? Then my ForkAndExec
routine from the previous posting will just work fine for you.

Untested:

my %pids = ();
my %devs = ();

sub FreeDevice($)
{
  my ($dev) = @_;
  my $pid = $pids{$dev}
    or return undef;
  kill $SIGNAL => $pid;
  waitpid $pid, 0;
  undef $pids{$dev}, $devs{$pid};
  return 1;
}

sub StartFile($$)
{
  my ($dev, $file) = @_;
  FreeDevice $dev; # and perhaps do some error handling
  $pids{$dev} = ForkAndExec play => '-d', $dev, $file;
  $devs{$pids{$dev}} = $dev; # reverse mapping
}

Yes, I do know the processes are left as zombies until the same device
is accessed again. That's to make sure the right process is killed -
and not another process that just has got the same PID as the old one
because it exited too early.

If you want prevent that, you would need a SIGCHLD handler you disable
while you're in the routine. Not really easy if you want to be sure not
to lose any signal.


-- 
Tota est omnis divisa in partes tres quarum unam incolunt Newbii aliam
Totarianii tertiam qui ipsorum lingua 'Domusvicus' nostra Trolli
appellantur.                                      [Thomas Dahmen in tota]


------------------------------

Date: Mon, 28 Apr 2003 19:45:29 +1000
From: "Tony" <anthony@movielink.net.au>
Subject: Re: Get PID from process started by "system" - how?
Message-Id: <pan.2003.04.28.09.45.28.158591@movielink.net.au>

On Mon, 28 Apr 2003 08:39:37 +0000, Rudolf Polzer wrote:

> Scripsit ille aut illa »Tony« <anthony@movielink.net.au>:
>> I will try and explain in more detail.
>> --------------------------------------
>> 
>> I run a "main" perl program.  Its task is to
>> keep reading a file which contains a "program"
[...]

>> My idea was to pick up the PID from the "play" program, store that
>> in a PID file together with the DEVICE number and let the main perl
>> program continue checking for matches in the "program" schedule.
> 
> You use the same 'play' program I know? Then my ForkAndExec
> routine from the previous posting will just work fine for you.

I will need to look at it - not sure how this would fit into
my play program...

My play program is something like this (Simplified):


main program...

DAY,TIME match > collect file names and pass to a sub with fork,
let the "forked" sub send the files to the play_file() one by one
untill there are no more files to play and self-destruct or get
killed if another DAY,TIME match hapens before it has finished.
    

sub play_file($file_name) { # sub with a file name passed to the sub.

  my $play_program = "/usr/bin/play";
  my file = $file_name;
  system "$play_file $file";

### or alteernatively..

  system `$play_program $file`;
  return (0) # Success
}


There is a lot more in there but not relevant to the problem
I have...

I do not quite get what is hapening below...it looks like a
variation of the above with the fork within it.

How would you play the list of files remembering that the
main program still needs to run checking for new events
to handle?  Or is the suggestion below a "second fork"
to be used after a first fork? 

Where do the %pids come from? (Only the forked process ID
as far as I can see).  Killing the forked perl process
will not kill the play process... 

> Untested:
> 
> my %pids = ();
> my %devs = ();
> 
> sub FreeDevice($)
> {
>   my ($dev) = @_;
>   my $pid = $pids{$dev}
>     or return undef;
>   kill $SIGNAL => $pid;
>   waitpid $pid, 0;
>   undef $pids{$dev}, $devs{$pid};
>   return 1;
> }
> 
> sub StartFile($$)
> {
>   my ($dev, $file) = @_;
>   FreeDevice $dev; # and perhaps do some error handling
>   $pids{$dev} = ForkAndExec play => '-d', $dev, $file;
>   $devs{$pids{$dev}} = $dev; # reverse mapping
> }
> 
> Yes, I do know the processes are left as zombies until the same device
> is accessed again. That's to make sure the right process is killed -
> and not another process that just has got the same PID as the old one
> because it exited too early.
> 
> If you want prevent that, you would need a SIGCHLD handler you disable
> while you're in the routine. Not really easy if you want to be sure not
> to lose any signal.

It is probably better to get the fundamentals going before
doing complex stuff...:-))

-- 
--------------------------------------------------------------
To reply directly send to: anthony AT movielink DOT net DOT au
Replace AT and DOT with @ and . and mail will get through.
Any spammers will be persued until they get booted off the net



------------------------------

Date: 28 Apr 2003 01:53:49 -0700
From: pkvinu@indiatimes.com (Vinod. K)
Subject: How to compress and uncompress the files using the perl program
Message-Id: <bde4ceed.0304280053.2efed33b@posting.google.com>

Hello All,


I am having a bunch of compressed files(database files, i.e .dbf files
whose size is more than 1GB) in one area. All these files need to be
uncompressed  one after the other and put them in other location using
perl script. presently I used - system "uncompress" - statement in my
perl script which is consuming considerably more time. Just I want
know is there any module or any other command in perl which will
perform the above said activity in lesser time???

please help me.


Thanks in advance,
 - Vinod.


------------------------------

Date: 28 Apr 2003 09:07:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to compress and uncompress the files using the perl program
Message-Id: <b8ir0k$bl2$2@mamenchi.zrz.TU-Berlin.DE>

Vinod. K <pkvinu@indiatimes.com> wrote in comp.lang.perl.misc:
> Hello All,
> 
> 
> I am having a bunch of compressed files(database files, i.e .dbf files
> whose size is more than 1GB) in one area. All these files need to be
> uncompressed  one after the other and put them in other location using
> perl script. presently I used - system "uncompress" - statement in my
> perl script which is consuming considerably more time. Just I want
> know is there any module or any other command in perl which will
> perform the above said activity in lesser time???

There may be such modules, but they won't run significantly faster.
All you can save is the call time for an external program.  The time-
consuming expansion will be the same in both cases.

Anno


------------------------------

Date: Mon, 28 Apr 2003 10:57:37 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: Netscape Enterprise 3.5 and flock
Message-Id: <3EACFB11.6030108@amtrak.co.uk>

h8dnwld wrote:
> I have a client that has a unpatched netscape enterprise 3.5 intranet web
> server on novell 4.11.  Upgrading or moving them to something better is
> not a option.  Can anyone tell me what the equivalent to Fcntl ':flock';


what have you tried?

# All Perl modules shipped with the standard distribution are included 
in the NetWare. Some of the standard modules that get shipped with 
NetWare are Fcntl, IO and SDBM_FILE.

http://developer.novell.com/ndk/doc/perl5/index.html?page=/ndk/doc/perl5/prl57enu/data/h4cr34aj.html


> so I can gain a exclusive lock on a file that 15-20 users are trying to
> update?  I have no documentation with the server nor have I had any luck

www.novell.com -> support -> documentation -> by product -> a-z -> 
developer -> Perl

> on the Netscape enterprise web site.  Any direction would be appreciated.
> 
> m




------------------------------

Date: 27 Apr 2003 23:12:31 -0700
From: srigowrisn@hotmail.com (shree)
Subject: Re: perl hash - help request
Message-Id: <49b5740e.0304272212.4756fbdb@posting.google.com>

John/Michael/James,

Thank very much for your responses. Both John's and Michael's snippett
worked perfectly..if I can be help in anyway, please do not hesitate
to ask.

Regards,
Shree


------------------------------

Date: 28 Apr 2003 09:00:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl hash - help request
Message-Id: <b8iqk4$bl2$1@mamenchi.zrz.TU-Berlin.DE>

Michael Budash  <mbudash@sonic.net> wrote in comp.lang.perl.misc:

[...]

>         $early++ if ("$iy$im$id" lt "$ry$rm$rd");
>         $on++    if ("$iy$im$id" eq "$ry$rm$rd");
>         $late++  if ("$iy$im$id" gt "$ry$rm$rd");

 ...or in one line:

    ${ ( \ ( $early, $on, $late))[ 1 + ( "$iy$im$id" cmp "$ry$rm$rd")] ++;

:)

Anno


------------------------------

Date: Mon, 28 Apr 2003 07:26:08 GMT
From: Scarrbunny <Scarr@bunny.com>
Subject: RE: Receive Authorize.NET AIM response from SSL port 443 and Parse
Message-Id: <Xns936B242BA59B2Scarrbunnycom@hop-hop-hop-splat>

I'm attempting to setup a checkout script for use with Authorize.NET's 
payment gateway using AIM (Merchant account provider doesn't allow SIM). I 
use a multi-part script for giving my user forms to gather the required 
information, verify, and process, and return a new form for more options. 
Then I send the final page to the Authorize.NET gateway via a POST form 
and....that's where I get stuck. I receive the response code returned to 
the browser window, so I know I'm properly comunicating with the gateway, 
but I can't go from there.

My question is how can I get the returned information to go into a script 
that I can use to format a final confirmation page for my users. I can 
specify a relay destination in the gateway configuration. I thought of 
using this method to post the information to a script, but wasn't sure 
exactly how to go about making the output of the script come back to the 
proper browser window for the proper user. Before I put much thought into 
that option, however, I got ahold of support at Auth.NET and they would 
simply tell me that I needed to make a connection to both send and receive 
and not post the information from a form. That was all they would tell me, 
however, as they "don't provide scripting support for AIM" I can't imagine 
why a company would encourage(read force) you to use one method and only 
support the other. Oh wait, I can, they offered me a link to a nice cgi 
file I could buy for a few hundred bucks...


Any help would be greatly appreciated by me and, I believe many others, as 
I have been searching and trial and erroring unsuccessfully for about 28 
hours now.

TIA

Scarr




------------------------------

Date: 28 Apr 2003 07:00:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex greediness question
Message-Id: <b8ijjb$5fr$1@mamenchi.zrz.TU-Berlin.DE>

Pierre Asselin  <pa@brick.invalid> wrote in comp.lang.perl.misc:
> Kevin Shay <kevin_shay@yahoo.com> wrote:
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<b89fe6$3bn$1@mamenchi.zrz.TU-Berlin.DE>...
> 
> > What do you think of this approach?
> 
> > $html =~ s[(<table>.*?</table>)][ deal_with_a_table($1) ]egi;
> 
> > sub deal_with_a_table {
> > ...
> > }
> 
> What if the tables are nested?  It's quite legal to do so in HTML.

 ...as has been noted in this thread:

> > makes the middle part non-greedy.  This seems to work, but only as
> > long as there are no nested tables.  If there are, a straightforward
> > regex doesn't cut it anymore.

The assumption here is that the tables don't nest.

Anno


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4903
***************************************


home help back first fref pref prev next nref lref last post