need help, will pay

Discussion in 'Perl Misc' started by boman, Sep 2, 2009.

  1. boman

    boman Guest

    Need help with a simple Perl cgi script running from Apache 2.2 on
    Windows XP, willing to pay $100 for the solution. Please email me for
    details. Prefer NYC-based coder, payment in cash.
     
    boman, Sep 2, 2009
    #1
    1. Advertising

  2. boman

    Nathan Keel Guest

    boman wrote:

    > Need help with a simple Perl cgi script running from Apache 2.2 on
    > Windows XP, willing to pay $100 for the solution. Please email me for
    > details. Prefer NYC-based coder, payment in cash.


    Why don't you post what the error is and the relevant portions of the
    script? You can probably get good help for no charge right now.
     
    Nathan Keel, Sep 2, 2009
    #2
    1. Advertising

  3. boman

    boman Guest

    On Sep 2, 12:49 pm, Nathan Keel <> wrote:
    > boman wrote:
    > > Need help with a simple Perl cgi script running from Apache 2.2 on
    > > Windows XP, willing to pay $100 for the solution. Please email me for
    > > details. Prefer NYC-based coder, payment in cash.

    >
    > Why don't you post what the error is and the relevant portions of the
    > script?  You can probably get good help for no charge right now.


    This question has been asked before, and I've tried almost all of the
    solutions, with no success. So I'm trying not to annoy this group by
    asking the question again. After the reading the "why doesn't this
    work" thread from Aug 20, I didn't want to start another brawl.

    But you graciously asked, Nathan, so here goes!

    1. display web page with simple form w/ radio buttons
    2. user selects radio button and clicks submit
    3. single parameter is passed from the radio button
    4. exe command on web server is initiated (I was using
    Win32::process), parameter is passed
    5. output of command is sent back to browser in real time (this is
    where I'm stuck)
    6. when command is done, start 2nd command, send output to browser in
    real time

    I've got 1-4 working, but cannot get output of command to the browser
    in real time, as the output is generated. It simply waits for command
    to finish, then sends the entire out put in one blob.

    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).

    Yes, I've read the stonehenge article which uses traceroute as an
    example, but cannot get that to work on my Windows perl v5.8.8. I
    tried some of the concepts from this article, but it's a bit out of my
    league.

    At this point I cannot spend much more time trying to get this to work
    myself, and I need a simple, yet professional level solution. I've
    read lots of forums, paged thru numerous books, I can't really spend
    time on that anymore. I need something that works, and I need it this
    week.

    I know this can probably be done in javascript, but I'd prefer this to
    be done in Perl. Also, I won't be able to install any modules, we'll
    have to use what's installed by default.

    thanks!
     
    boman, Sep 2, 2009
    #3
  4. boman

    Brian Wakem Guest

    boman wrote:

    > On Sep 2, 12:49 pm, Nathan Keel <> wrote:
    >> boman wrote:
    >> > Need help with a simple Perl cgi script running from Apache 2.2 on
    >> > Windows XP, willing to pay $100 for the solution. Please email me for
    >> > details. Prefer NYC-based coder, payment in cash.

    >>
    >> Why don't you post what the error is and the relevant portions of the
    >> script?  You can probably get good help for no charge right now.

    >
    > This question has been asked before, and I've tried almost all of the
    > solutions, with no success. So I'm trying not to annoy this group by
    > asking the question again. After the reading the "why doesn't this
    > work" thread from Aug 20, I didn't want to start another brawl.
    >
    > But you graciously asked, Nathan, so here goes!
    >
    > 1. display web page with simple form w/ radio buttons
    > 2. user selects radio button and clicks submit
    > 3. single parameter is passed from the radio button
    > 4. exe command on web server is initiated (I was using
    > Win32::process), parameter is passed
    > 5. output of command is sent back to browser in real time (this is
    > where I'm stuck)
    > 6. when command is done, start 2nd command, send output to browser in
    > real time
    >
    > I've got 1-4 working, but cannot get output of command to the browser
    > in real time, as the output is generated. It simply waits for command
    > to finish, then sends the entire out put in one blob.
    >
    > 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



    A quick and easy way around browser buffering is to print something like
    this 100 or so times after every line you output.

    <!-- this wont show up on the page but will force the browser to flush -->



    --
    Brian Wakem
     
    Brian Wakem, Sep 2, 2009
    #4
  5. boman <> wrote:
    >1. display web page with simple form w/ radio buttons
    >2. user selects radio button and clicks submit
    >3. single parameter is passed from the radio button
    >4. exe command on web server is initiated (I was using
    >Win32::process), parameter is passed
    >5. output of command is sent back to browser in real time (this is
    >where I'm stuck)
    >6. when command is done, start 2nd command, send output to browser in
    >real time
    >
    >I've got 1-4 working, but cannot get output of command to the browser
    >in real time, as the output is generated. It simply waits for command
    >to finish, then sends the entire out put in one blob.


    As has been explained to you back then this is _NOT(!)_ a Perl issue but
    a problem somewhere in the long chain of receiving CGI response,
    creating and sending HTTP response, receiving HTTP response, rendering
    the page in the browser. You really need someone who is familiar with
    those areas (no matter in which language) instead of someone who is
    familiar with Perl.

    In short: you are barking up the wrong tree.

    >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).


    As I said, you need someone who is familiar with web programming, not
    someone familiar with Perl.

    >I know this can probably be done in javascript, but I'd prefer this to
    >be done in Perl.


    That is not possible! Please, please, please, you already set the Perl
    buffer to auto-flush. There REALLY is nothing else you can do in your
    Perl code.

    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.

    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.

    jue
     
    Jürgen Exner, Sep 2, 2009
    #5
  6. boman

    boman Guest

    On Sep 2, 2:03 pm, Jürgen Exner <> 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.

    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
     
    boman, Sep 2, 2009
    #6
  7. boman

    Nathan Keel Guest

    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).
     
    Nathan Keel, Sep 2, 2009
    #7
  8. boman

    boman Guest

    On Sep 2, 2:23 pm, Nathan Keel <> 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. The stonehenge
    traceroute script gave me ideas, but I can't get it to work, and I'm
    out of time for troubleshooting.
     
    boman, Sep 2, 2009
    #8
  9. boman <> wrote:
    >On Sep 2, 2:03 pm, Jürgen Exner <> 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
     
    Jürgen Exner, Sep 2, 2009
    #9
  10. boman <> wrote:
    >On Sep 2, 2:23 pm, Nathan Keel <> 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
     
    Jürgen Exner, Sep 2, 2009
    #10
  11. boman <> wrote:
    > On Sep 2, 2:23 pm, Nathan Keel <> 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 ___
    \__________________________ http://toerring.de
     
    Jens Thoms Toerring, Sep 2, 2009
    #11
  12. boman

    boman Guest

    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;
    }
     
    boman, Sep 2, 2009
    #12
  13. boman

    Nathan Keel Guest

    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.
     
    Nathan Keel, Sep 2, 2009
    #13
  14. boman

    Ron Bergin Guest

    On Sep 2, 12:26 pm, 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.
    >
    > #!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 iswrong"), 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;
    >
    > }
    >
    >


    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/Wrapper.pm
     
    Ron Bergin, Sep 2, 2009
    #14
  15. 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
     
    Martijn Lievaart, Sep 2, 2009
    #15
  16. boman

    Ron Bergin Guest

    On Sep 2, 10:06 am, 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).
    >


    If you run the script from the command line, you'll see that the issue
    not that the browser is buffering the netstat output, the netstat
    command is buffering its output.
     
    Ron Bergin, Sep 2, 2009
    #16
  17. On 2009-09-02 19:09, Jens Thoms Toerring <> wrote:
    > boman <> wrote:
    >> On Sep 2, 2:23 pm, Nathan Keel <> 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.


    I think you haven't read the "stonehenge article" mentioned by boman.
    Here it is: http://www.stonehenge.com/merlyn/LinuxMag/col39.html

    > 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).


    No, the idea is to have a long-running process just write information to
    a file. The CGI script then just has to look at the file to determine
    what it should send back to the client.

    >
    > 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.


    Just use several background processes.

    > And you would have to rely on some mechanism, e.g. cookies, to know
    > which results are for which client.


    Query parameters are more reliable for that.

    hp
     
    Peter J. Holzer, Sep 4, 2009
    #17
  18. Jens Thoms Toerring, Sep 5, 2009
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Johnson

    Need a few lines of code help, will pay!

    Robert Johnson, Aug 3, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    332
    makthar
    Aug 4, 2003
  2. WEB 1040
    Replies:
    2
    Views:
    409
    Smike
    Apr 6, 2005
  3. Bob
    Replies:
    26
    Views:
    933
  4. master0515
    Replies:
    0
    Views:
    373
    master0515
    Nov 12, 2003
  5. shree jayendra

    need help with eway pay,ent gateway

    shree jayendra, Jun 16, 2009, in forum: Ruby
    Replies:
    0
    Views:
    208
    shree jayendra
    Jun 16, 2009
Loading...

Share This Page