Perl CGI & File I/O Problem

M

Mike

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
 
A

A. Sinan Unur

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
 
J

Joe Smith

Mike said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top