Perl CGI & File I/O Problem

Discussion in 'Perl Misc' started by Mike, Apr 7, 2005.

  1. Mike

    Mike Guest

    I have a simple Perl script that works good as a standalone script that
    I want to migrate to work from a web page link.

    The script opens a file and does a couple greps to pull out specific
    lines from the file and report to the user.

    For the CGI script (not using CGI pm and can not use it) as soon as I
    hit the open statement all output to the web page stops. For example:

    {All the html header stuff printed before this}

    printf("Line 1");
    open ...
    printf("Line 2");

    I will see Line 1 but not Line 2

    I put all the file i/o and grep/substr work in a sub and called it
    first and now I get an Internal Server Error message. Looks like no
    output is being generated at all.

    If I comment out the open statement I see all my literals output minus
    the info I read from the file.

    It almost appears that when I hit the open statement, perl loses the
    standard out file handle - ?

    Is there something special I'm missing about using file IO in a CGI
    script?


    Any help would be appreciated.


    Thanks
    Mike
     
    Mike, Apr 7, 2005
    #1
    1. Advertising

  2. "Mike" <> wrote in
    news::

    > I have a simple Perl script that works good as a standalone script
    > that I want to migrate to work from a web page link.
    >
    > The script opens a file and does a couple greps to pull out specific
    > lines from the file and report to the user.
    >
    > For the CGI script (not using CGI pm and can not use it)


    Why not?

    > printf("Line 1");
    > open ...
    > printf("Line 2");


    ....

    > Is there something special I'm missing about using file IO in a CGI
    > script?


    Well, there is really no information upon which one can provide any
    pertinent advice. All I can do is to suggest that you read:

    perldoc -q 500
    perldoc -q CGI

    and the posting guidelines for this group.

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Apr 7, 2005
    #2
    1. Advertising

  3. Mike <> wrote:

    > (not using CGI pm and can not use it)



    Why is it that you cannot use the CGI module?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Apr 7, 2005
    #3
  4. Mike

    Joe Smith Guest

    Mike wrote:

    > Is there something special I'm missing about using file IO in a CGI
    > script?


    Don't use die() unless you have ensured that the required HTTP
    headers have been output first.

    Be careful when using select() - it can redirect output that would have
    gone to STDOUT.

    Never attempt to access /dev/tty in a CGI program.

    Post a short but complete program so that we can attempt to
    reproduce your problem.

    -Joe
     
    Joe Smith, Apr 7, 2005
    #4
    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. Jürgen Exner

    Re: CGI Perl "use CGI" statement fail

    Jürgen Exner, Jul 31, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,616
    Jürgen Exner
    Jul 31, 2003
  2. praba kar

    Python-cgi or Perl-cgi script doubt

    praba kar, Jul 30, 2005, in forum: Python
    Replies:
    1
    Views:
    808
    Michael Sparks
    Jul 30, 2005
  3. excord80
    Replies:
    17
    Views:
    865
    J Kenneth King
    Jan 29, 2009
  4. BestFriend
    Replies:
    2
    Views:
    916
  5. kath
    Replies:
    4
    Views:
    807
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page