I'm stumped and am looking for some ideas.

I have a program that will (via a web form) accept a file containing comma-separated values, store that file somewhere, then re-open the file, processing each line and inserting the data as rows in a MySQL database.

When I run my unit tests from the command line, everything appears to work perfectly. When I actually use a web browser to run the program via CGI, the program works fine except that it doesn't process the last few rows of the uploaded file. It appears to not read them at all!

I would think that there is a problem with the upload, except that the program accepts the uploaded file, stores it, then opens and processes the stored file. Because the file remains on the disk after processing, I can have my unit tests use the previously stored file and the file will be processed perfectly.

Obviously there is something different about running the program from the command line as opposed to running it via CGI.

My first thought was that, since the CGI version would run as user "nobody", it would therefore would have a different environment. However, when I su'd to be nobody and ran the unit tests, they worked fine.

Does anyone have any suggestions on other ways in which the command-line environment would differ from the CGI environment in such a way as to cause this behavior? Or suggestions on ways to find the cause? (The code is lengthy, so I'm not sure that showing it would really be that helpful.)

Wally "Mystified" Hartshorn

(Plug: Visit JavaJunkies, PerlMonks for Java)


In reply to Differing Behavior as CGI vs. Command Line by Wally Hartshorn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.