[31335] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2580 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 2 18:09:46 2009

Date: Wed, 2 Sep 2009 15:09:10 -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           Wed, 2 Sep 2009     Volume: 11 Number: 2580

Today's topics:
        Connect to DB2 remote host from client? <BLOCKSPAMfishfry@your-mailbox.com>
    Re: Connect to DB2 remote host from client? <ben@morrow.me.uk>
    Re: create a form with cgi and a multidimensional array sln@netherlands.com
        FAQ 4.29 How can I count the number of occurrences of a <brian@theperlreview.com>
    Re: getopts::long & option string argument <tadmc@seesig.invalid>
    Re: getopts::long & option string argument <uri@StemSystems.com>
        Help me with authomatic authentication <gervaz@gmail.com>
    Re: How to get current directory path <news@lawshouse.org>
    Re: need help, will pay <shambo_p@yahoo.com>
    Re: need help, will pay <nat.k@gm.ml>
    Re: need help, will pay <shambo_p@yahoo.com>
    Re: need help, will pay <jurgenex@hotmail.com>
    Re: need help, will pay <jurgenex@hotmail.com>
    Re: need help, will pay (Jens Thoms Toerring)
    Re: need help, will pay <shambo_p@yahoo.com>
    Re: need help, will pay <nat.k@gm.ml>
    Re: need help, will pay <rkb@i.frys.com>
    Re: need help, will pay <m@rtij.nl.invlalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 02 Sep 2009 12:24:57 -0700
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Connect to DB2 remote host from client?
Message-Id: <BLOCKSPAMfishfry-D2A83C.12245702092009@news.giganews.com>

I have my DBI/DB2 code running locally with no problems, using the DB2 
driver downloaded from IBM.

However I need to access this database from client machines that may not 
have DB2 installed. The documentation is kind of sketchy on this point. 
Do I have to install some kind of special client-side driver to install 
and use DBI::DB2 from a machine that is not running DB2?


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

Date: Wed, 2 Sep 2009 22:37:04 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Connect to DB2 remote host from client?
Message-Id: <0553n6-pjf2.ln1@osiris.mauzo.dyndns.org>


Quoth fishfry <BLOCKSPAMfishfry@your-mailbox.com>:
> I have my DBI/DB2 code running locally with no problems, using the DB2 
> driver downloaded from IBM.
> 
> However I need to access this database from client machines that may not 
> have DB2 installed. The documentation is kind of sketchy on this point. 
> Do I have to install some kind of special client-side driver to install 
> and use DBI::DB2 from a machine that is not running DB2?

I don't know about DB2 specifically, but generally client-server
databases have a client library that needs to be installed on the client
machines. This is usually completely independant of the database server
itself.

Ben



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

Date: Wed, 02 Sep 2009 12:33:50 -0700
From: sln@netherlands.com
Subject: Re: create a form with cgi and a multidimensional array
Message-Id: <tugt95h84jntnsrqtmdpb7sqoa42kk71td@4ax.com>

On Wed, 2 Sep 2009 02:00:51 -0700 (PDT), Marek <mstep@podiuminternational.org> wrote:

>Hello all!
>
>
>I have a cgi problem, which I can not resolve alone.
>
>I have a multidimensional array, to create a form like follows:
>
>my @element_liste = (
>    {
>        type => "text",
>        name => "firma",
>        bez  => "Firma:",
>        size => 36
>    },
>
>etc.
>
>my cgi script iterates over this array to create the form:
>
>foreach my $f ( @{$element_liste_ref} ) {
>        my $type = $f->{type};
>        my $bez  = $f->{bez};
>        if ( $type eq "text" ) {
>            push(
>                @zeile,
>                Tr(
>                    td($bez),
>                    td(
>                        textfield(
>                            -name => $f->{name},
>                            -size => $f->{size}
>                        )
>                    )
>                )
>            );
>        }}
>
>etc
>
>Like that every table row is stocked into @zeile for later printing,
>like follows:
>
>tr
>=================================================================
>td				td
>	| $bez 		|  <input type="text" name="firma" size="36" /
>>                             |
>=================================================================
>
>But now I have the problem, that I need to add a dimension more for
>the date. Explication:
>
>,
>    {
>        type  => "popup",
>        name  => "time",
>        bez   => "day/month/year/ - hh:mm",
>        value => [ "01", "02", "03", etc. ]
>    },
>    {
>        type  => "popup",
>        name  => "time",
>        bez   => "day/month/year/ - hh:mm",
>        value => [ "Jan", "Feb", etc. ],
>    },
>    {
>        type  => "popup",
>        name  => "time",
>        bez   => "day/month/year/ - hh:mm",
>        value => [ "2009", "2010", "2011", "2012" ],
>    }
>
>etc
>
>And I need the cgi to creat *ONE* table row only with day/month/year -
>hour:min
>
>tr
>=================================================================
>td				td
>	| $bez 		|  <select name="time"> 					                        |
>	|			|	<option value="01">							        |
>	|			|		01 = days								                |
>	|			|		   etc. 								                |
>	|			|	same for /month/year - hour:min				                |
>=================================================================
>
>
>Could be somebody so kind, to help me with this?
>
>
>
>Best greetings from Munich
>
>
>
>marek

I know html from the parsing side, so I threw this together.
You should know what you can get out of html before
you start using cgi I guess, therefore my trivial solution.

I looked over cgi.pm the other day, its entirely bizzare.
The documentation sucks, so I thought I'd look into it.
Its not clear how you can retrieve information from a form.
I know -name=> stuff, but is it on a record basis, probably.

You have to figure that out for yourself.

The Tr() td() th() shortcuts should work in a nexting fashion,
but I didn't check cgi.pm and it doesen't say in the perl docs.

The other thing is I have no idea what you are trying to do.

Ideally, you want the output, in the case of a record containing
popups that aren't grouped, to be of this form, which works:

 <TR align=right bgColor=#fffff0>
    <TD colspan="5">cars
       <select  name="Foreign">
          <option value="volvo">Volvo</option>
          <option value="saab">Saab</option>
          <option value="mercedes">Mercedes</option>
          <option value="audi">Audi</option>
       </select>
       <select  name="Domestic">
          <option value="ford">Ford</option>
          <option value="chevy">Chevy</option>
          <option value="chrysler">Chrysler</option>
          <option value="gm">GM</option>
          </select>
    </TD>

You should be able to next the popups in one TD,
giving each a different 'name', assuming you can 
acess 'named' items on a row basis.

In your case you have a mix of individual popups for each
of day, month, year AND apparently, a text input for time
(which was not accounted for in the mix).

Because your simple definition of types do not cover
generalization of nesting. For that, you need something more
sophisticated which I am not spedning time here today because
I don't believe in the principle utilities of dynamic generation
that cgi.pm provieds. I would much rather have pre-formed, mild
editing, ready to pop in the oven type of stuff.

I have nothing against dynamic generation, but when you build
the same page over and over again from scratch only to change
one small thing, it wastes resources. There are better ways.

Anyway here is my untested solution.
Ps. Quote only relavent parts if you respond.

Good luck!
-sln

============================
my @element_liste = (
    {
        type => 'text',
        name => "firma',
        bez  => 'Firma:',
        size => 36
    },
    { },
    { },
    { },
    {
        type  => 'popup',
        bez   => 'day/month/year/ - hh:mm',
        $puitems => [
            {
               name  => 'day',
               value => [ '01', '02', '03', etc. ]
            },
            {
               name  => 'month',
               value => [ 'Jan', 'Feb', etc. ],
            },
            {
               name  => 'year',
               value => [ '2009', '2010', '2011', '2012' ],
            }
        ]
     }
);

foreach my $f ( @{$element_liste_ref} )
{
        my $type = $f->{type};
        my $bez  = $f->{bez};
        if ( $type eq 'text' )
        {
            push @zeile,
                  Tr(
                      td($bez),
                      td( textfield(-name => $f->{name},-size => $f->{size} ))
                    );
        }
        elsif ( $type eq 'popup' )
        {
            my @menus;
            for (@$puitems) {
                push @menus,
                     popup_menu(
                          -name   => $_->{name},
                          -values => $_->{value}
                     );
             }
             push @zeile,
                  Tr(
                      -align => RIGHT, -bgColor => #fffff0,
                      td(
                          -colspan => "2",
                          $f->{bez},
                          @menus
                        )
                     );
        }
        elsif ( $type eq 'more here' )
        {
            # add more
        }
}





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

Date: Wed, 02 Sep 2009 22:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 4.29 How can I count the number of occurrences of a substring within a string?
Message-Id: <CVBnm.136630$cf6.74091@newsfe16.iad>

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

4.29: How can I count the number of occurrences of a substring within a string?

    There are a number of ways, with varying efficiency. If you want a count
    of a certain single character (X) within a string, you can use the
    "tr///" function like so:

            $string = "ThisXlineXhasXsomeXx'sXinXit";
            $count = ($string =~ tr/X//);
            print "There are $count X characters in the string";

    This is fine if you are just looking for a single character. However, if
    you are trying to count multiple character substrings within a larger
    string, "tr///" won't work. What you can do is wrap a while() loop
    around a global pattern match. For example, let's count negative
    integers:

            $string = "-9 55 48 -2 23 -76 4 14 -44";
            while ($string =~ /-\d+/g) { $count++ }
            print "There are $count negative numbers in the string";

    Another version uses a global match in list context, then assigns the
    result to a scalar, producing a count of the number of matches.

            $count = () = $string =~ /-\d+/g;



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Wed, 02 Sep 2009 14:48:44 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: getopts::long & option string argument
Message-Id: <slrnh9tick.dd.tadmc@tadmc30.sbcglobal.net>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> [Quoting in full]
> James Spahlinger <james.news@nixeagle.org> wrote:
>>Florian Kaufmann wrote:
>>
>>> What can Getopt::Long, or any other 'standard' 
>>module offer me for
>>> this problem task:
>>> 
>>> I have an option which expects a string 
>>argument. But a) only a finite
>>> set of strings are to be accepted b) unique 
>>abbreviations shall be
>>> accepted, e.g. if the set of valid strings is 
>>("foo","bar","fly") then
>>> "fo" should stand for "foo".
>>> 
>>> An example for such a use case is the --
>>backup[=CONTROL] option of
>>> many coreutils tools as for example cp, ln, 
>>install. CONTROL can only
>>> be ("no","off","numbered"... and a few more).
>>What you want to do is exactly what Getopt is 
>>for.
>
> What on earth did you do with the quoted text. You _REALLY_ should check
> your quoting style. It is absolutely impossible to tell what you were
> quoting and what you were saying.


But it is a pretty good bellweather of the quality of the comment offered...


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 02 Sep 2009 16:26:53 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: getopts::long & option string argument
Message-Id: <87y6oxdrea.fsf@quad.sysarch.com>

>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:

  TJM> Jürgen Exner <jurgenex@hotmail.com> wrote:
  >> [Quoting in full]
  >> James Spahlinger <james.news@nixeagle.org> wrote:
  >>> Florian Kaufmann wrote:
  >>> 
  >>>> What can Getopt::Long, or any other 'standard' 
  >>> module offer me for
  >>>> this problem task:
  >>>> 
  >>>> I have an option which expects a string 
  >>> argument. But a) only a finite
  >>>> set of strings are to be accepted b) unique 
  >>> abbreviations shall be
  >>>> accepted, e.g. if the set of valid strings is 
  >>> ("foo","bar","fly") then
  >>>> "fo" should stand for "foo".
  >>>> 
  >>>> An example for such a use case is the --
  >>> backup[=CONTROL] option of
  >>>> many coreutils tools as for example cp, ln, 
  >>> install. CONTROL can only
  >>>> be ("no","off","numbered"... and a few more).
  >>> What you want to do is exactly what Getopt is 
  >>> for.
  >> 
  >> What on earth did you do with the quoted text. You _REALLY_ should check
  >> your quoting style. It is absolutely impossible to tell what you were
  >> quoting and what you were saying.


  TJM> But it is a pretty good bellweather of the quality of the comment
  TJM> offered...

beyond that, you CAN do what the OP wants with getopt::long using a
callback sub which is a closure. it would contain the hash of valid
values as well as a ref to the variable to set. see the docs for how to
use that. also Getopt::Euclid has code constraints that allow this very
thing as well and it does much more including pod and usage generation
all in one.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: 02 Sep 2009 22:08:03 GMT
From: mattia <gervaz@gmail.com>
Subject: Help me with authomatic authentication
Message-Id: <4a9eecc3$0$43595$4fafbaef@reader1.news.tin.it>

I just need to automatically authenticate to the following webpage:
http://pf.rossoalice.alice.it/login.html
Notice that the webpage has numerous redirect.

Can you help me?


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

Date: Wed, 02 Sep 2009 22:46:06 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: How to get current directory path
Message-Id: <CIudnacy2ZABegPXnZ2dnUVZ8mdi4p2d@giganews.com>

moonhkt wrote:
> Hi All
> 
> How to get current directory path ?

use strict; use warnings;

print "Hey, what's the current directory?";
my $cd = <>;
print "Current directory is $cd";

-- 

Henry Law            Manchester, England


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

Date: Wed, 2 Sep 2009 11:19:12 -0700 (PDT)
From: boman <shambo_p@yahoo.com>
Subject: Re: need help, will pay
Message-Id: <0dca6c78-6a9d-4523-9ae5-2757a3c8522d@p23g2000vbl.googlegroups.com>

On Sep 2, 2:03=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> As I said, you need someone who is familiar with web programming, not
> someone familiar with Perl.
>
> You said yourself that the buffering probably happens in the brower.
> Maybe so, maybe somewhere else in the chain. But it really, really isn't
> Perl.

J=FCrgen, I've read your previous posts and I respect your opinion, but
I'm pretty sure what I'm asking for can be done in Perl, the
stonehenge article with the traceroute example seems to prove that. I
simply cannot spent any more time trying different things.

Hence the offer of money; if someone can provide me with a solution
based on the requirements (which include using Perl), than I will pay
cash.

> Aside of that, "in real time" is a non-starter to begin with because the
> HyperText Transfer Protocol is not real-time to begin with.
> If you need real time then you need to look into a different protocol,
> but that's even more off topic than web programming.

OK, not real time, how about updating the browser every 5 seconds? I
actually do have something like this working, but I can't get around
the browser buffer issue, and I'm pretty sure someone who knows Perl
very well can provide a clever solution to get around that. I simply
cannot spend any more time researching this, I need a solution now.

thanks





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

Date: Wed, 02 Sep 2009 11:23:04 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: need help, will pay
Message-Id: <cKynm.277188$E61.221867@newsfe09.iad>

boman wrote:

> Yes, I've got the $|=1 set, and I made sure apache is not buffering
> output, but can't get around the browsers doing the buffering (I think
> this is what's happening).
> 

I see, well then you might need to get someone to take a look or give
you different options.  There are some things you can try, but if
you've set the buffering in the script, then the problem does lie
elsewhere.  You also might consider something like a server-push
solution or just saying "click here to view the results", which can
then open a file or read in the data as its happening (perhaps not via
a CGI script).


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

Date: Wed, 2 Sep 2009 11:33:22 -0700 (PDT)
From: boman <shambo_p@yahoo.com>
Subject: Re: need help, will pay
Message-Id: <d78562af-a408-4fa6-b71c-187eaa9fa8b7@l35g2000vba.googlegroups.com>

On Sep 2, 2:23=A0pm, Nathan Keel <na...@gm.ml> wrote:
> I see, well then you might need to get someone to take a look or give
> you different options. =A0There are some things you can try, but if
> you've set the buffering in the script, then the problem does lie
> elsewhere. =A0You also might consider something like a server-push
> solution or just saying "click here to view the results", which can
> then open a file or read in the data as its happening (perhaps not via
> a CGI script).

The link idea could be a fall back, but I'd like to automate that. I
would think you can do that by setting the refresh parameter in
cgi::pm's header call, but I cannot figure out how to get the refresh
to exit once the process is complete, it just refreshes and refreshes
and refreshes, even when the process completes. The stonehenge
traceroute script gave me ideas, but I can't get it to work, and I'm
out of time for troubleshooting.


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

Date: Wed, 02 Sep 2009 11:54:38 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: need help, will pay
Message-Id: <eoet95lruktiv2hu0im3qt1uk3otu4uj4p@4ax.com>

boman <shambo_p@yahoo.com> wrote:
>On Sep 2, 2:03 pm, Jürgen Exner <jurge...@hotmail.com> wrote:
>> As I said, you need someone who is familiar with web programming, not
>> someone familiar with Perl.
>>
>> You said yourself that the buffering probably happens in the brower.
>> Maybe so, maybe somewhere else in the chain. But it really, really isn't
>> Perl.
>
>Jürgen, I've read your previous posts and I respect your opinion, but
>I'm pretty sure what I'm asking for can be done in Perl, the
>stonehenge article with the traceroute example seems to prove that. I
>simply cannot spent any more time trying different things.

Ok, one final attempt:

You are trying to haul a yard of sand with your pickup truck and it
doesn't work. You keep trying to convince the car mechanic to finally
fix the car while actually the problem is the washed out bridge to the
sand pit. 

This is exactly what you keep doing. You are looking for a solution in
Perl (your pickup) and keep asking Perl guys (your car mechanic) how to
fix the program (your pickup) while actually Perl (your pickup) is doing
just fine and the problem is not related to Perl (your pickup) at all
and you should be asking web programmers (the DOT) about how to
implement a non-bufferd path (fix the bridge).

>> Aside of that, "in real time" is a non-starter to begin with because the
>> HyperText Transfer Protocol is not real-time to begin with.
>> If you need real time then you need to look into a different protocol,
>> but that's even more off topic than web programming.
>
>OK, not real time, how about updating the browser every 5 seconds? I

If you mean updating the displayed document rather than the browser,
then HTML has such a directive, see "refresh" for HTTP-EQUIV. If that's
a good choice I don't know, probably not.

jue


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

Date: Wed, 02 Sep 2009 11:59:56 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: need help, will pay
Message-Id: <v1gt95pf1m4tk6tsvlba78b23084ql6fa7@4ax.com>

boman <shambo_p@yahoo.com> wrote:
>On Sep 2, 2:23 pm, Nathan Keel <na...@gm.ml> wrote:
>> I see, well then you might need to get someone to take a look or give
>> you different options.  There are some things you can try, but if
>> you've set the buffering in the script, then the problem does lie
>> elsewhere.  You also might consider something like a server-push
>> solution or just saying "click here to view the results", which can
>> then open a file or read in the data as its happening (perhaps not via
>> a CGI script).
>
>The link idea could be a fall back, but I'd like to automate that. I
>would think you can do that by setting the refresh parameter in
>cgi::pm's header call, but I cannot figure out how to get the refresh
>to exit once the process is complete, it just refreshes and refreshes
>and refreshes, even when the process completes. 

That is trivial to fix: for the final report, i.e. when the process is
finished, just _don't_ set the refresh parameter in that final document.
Problem solved.

jue


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

Date: 2 Sep 2009 19:09:39 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: need help, will pay
Message-Id: <7g7u7jF2m5kclU1@mid.uni-berlin.de>

boman <shambo_p@yahoo.com> wrote:
> On Sep 2, 2:23 pm, Nathan Keel <na...@gm.ml> wrote:
> > I see, well then you might need to get someone to take a look or give
> > you different options.  There are some things you can try, but if
> > you've set the buffering in the script, then the problem does lie
> > elsewhere.  You also might consider something like a server-push
> > solution or just saying "click here to view the results", which can
> > then open a file or read in the data as its happening (perhaps not via
> > a CGI script).

> The link idea could be a fall back, but I'd like to automate that. I
> would think you can do that by setting the refresh parameter in
> cgi::pm's header call, but I cannot figure out how to get the refresh
> to exit once the process is complete, it just refreshes and refreshes
> and refreshes, even when the process completes.

That should be simple, just don't send the meta refresh anymore
with the last page when the program is done.

The real problem is more that this can't be done with a simple
CGI script because when the browser (re-)loads the page the
web server will start a new CGI script that doesn't know any-
thing about what happened before. So you will probably need
some background process that waits for requests from the CGI
script and then passes back the newly calculated data back to
it (which the CGI script then sends on to the web server that
transmits them to the browser).

Since there could be several browsers asking simultaneously
for new pages you also would have to be able to handle cal-
culations in parallel within that background process. And
you would have to rely on some mechanism, e.g. cookies, to
know which results are for which client.

                           Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Wed, 2 Sep 2009 12:26:04 -0700 (PDT)
From: boman <shambo_p@yahoo.com>
Subject: Re: need help, will pay
Message-Id: <8eb92dd5-b6d2-40f0-a5e3-a4bc67ed4937@33g2000vbe.googlegroups.com>

Here's the code so far. It continues to update the browser, although
it's sloppy, and when the process is done, it does display the "done"
page. But then it refreshes again in 5 seconds.



#!c:/Perl/bin/perl.exe

use CGI qw/:standard/;
use Win32::Process;
use Win32::Process qw/STILL_ACTIVE/;
use Win32;

$| = 1;

Win32::Process::Create($MainProcessObj,
	"c:\\WINDOWS\\System32\\netstat.exe",
	"netstat",
	0,
	NORMAL_PRIORITY_CLASS,
	".");
$MainProcessObj->GetExitCode($exitcode);

$counter = 0;
while ($exitcode != 1) {
	if ($exitcode == 0) {
		print header, start_html,h4("something is wrong"), end_html;
		exit;
	} else {
	print header(-Refresh=>"5"), start_html;
	print p("waiting, $counter secs... $exitcode "), end_html;
	$counter = $counter + 5;
	sleep 5;
	$MainProcessObj->GetExitCode($exitcode);
	}
}

if ($exitcode = "") {
	print header, start_html, p("done $exitcode"), end_html;
}


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

Date: Wed, 02 Sep 2009 13:27:11 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: need help, will pay
Message-Id: <zyAnm.128921$sC1.126708@newsfe17.iad>

boman wrote:

> Here's the code so far. It continues to update the browser, although
> it's sloppy, and when the process is done, it does display the "done"
> page. But then it refreshes again in 5 seconds.
> 

If you're happy with the result as it is and just don't want it to
refresh, just pass a variable to the script that let's the script know
that it's been refreshed (once) already and doesn't put in the refresh
header in that resulting document's (web page) output.



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

Date: Wed, 2 Sep 2009 14:03:47 -0700 (PDT)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: need help, will pay
Message-Id: <f4a0ffae-d3f8-4945-8501-682f941df921@12g2000pri.googlegroups.com>

On Sep 2, 12:26=A0pm, boman <shamb...@yahoo.com> wrote:
> Here's the code so far. It continues to update the browser, although
> it's sloppy, and when the process is done, it does display the "done"
> page. But then it refreshes again in 5 seconds.
>
> #!c:/Perl/bin/perl.exe
>
> use CGI qw/:standard/;
> use Win32::Process;
> use Win32::Process qw/STILL_ACTIVE/;
> use Win32;
>
> $| =3D 1;
>
> Win32::Process::Create($MainProcessObj,
> =A0 =A0 =A0 =A0 "c:\\WINDOWS\\System32\\netstat.exe",
> =A0 =A0 =A0 =A0 "netstat",
> =A0 =A0 =A0 =A0 0,
> =A0 =A0 =A0 =A0 NORMAL_PRIORITY_CLASS,
> =A0 =A0 =A0 =A0 ".");
> $MainProcessObj->GetExitCode($exitcode);
>
> $counter =3D 0;
> while ($exitcode !=3D 1) {
> =A0 =A0 =A0 =A0 if ($exitcode =3D=3D 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 print header, start_html,h4("something is=
 wrong"), end_html;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit;
> =A0 =A0 =A0 =A0 } else {
> =A0 =A0 =A0 =A0 print header(-Refresh=3D>"5"), start_html;
> =A0 =A0 =A0 =A0 print p("waiting, $counter secs... $exitcode "), end_html=
;
> =A0 =A0 =A0 =A0 $counter =3D $counter + 5;
> =A0 =A0 =A0 =A0 sleep 5;
> =A0 =A0 =A0 =A0 $MainProcessObj->GetExitCode($exitcode);
> =A0 =A0 =A0 =A0 }
>
> }
>
> if ($exitcode =3D "") {
> =A0 =A0 =A0 =A0 print header, start_html, p("done $exitcode"), end_html;
>
> }
>
>

Sloppy is an understatement.

Why are you printing/reprinting the html header in a loop and why the
'sleep'?

You should execute that script outside of the cgi environment and
remove the 'sleep' line to see why that's the wrong thing to do.

Rather than using Win32::Process, I think it would be better to use
Net::Netstat::Wrapper.

http://search.cpan.org/~mcantoni/Net-Netstat-Wrapper-0.03/lib/Net/Netstat/W=
rapper.pm


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

Date: Wed, 2 Sep 2009 23:10:38 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: need help, will pay
Message-Id: <ej33n6-qgj.ln1@news.rtij.nl>

On Wed, 02 Sep 2009 10:06:08 -0700, boman wrote:

> Yes, I've got the $|=1 set, and I made sure apache is not buffering
> output, but can't get around the browsers doing the buffering (I think
> this is what's happening).

Some (all?) versions of IE need 256 spaces first as start of the body. 
It's weird, but true. If your problem occurs in other browsers as well, 
this is not the solution, if your problem is only in IE, give it a try.

HTH,
M4


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 2580
***************************************


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