Problem serving a PDF

D

DMB

I have a Perl script that serves a PDF on a Unix server and it works
perfectly. The same script on Windows is not working. Can someone
tell me what obvious mistake I'm overlooking?

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

print "Cache-control: no-cache\n";
print "Content-type: application/pdf\n\n";
open (CODE, "C:/Program Files/Apache
Group/Apache2/htdocs/mp/corr/notfound.pdf") || die;
binmode STDOUT;
binmode CODE;
print <CODE>;
close (CODE);
exit;
 
P

Paul Lalli

DMB said:
I have a Perl script that serves a PDF on a Unix server and it works
perfectly. The same script on Windows is not working. Can someone
tell me what obvious mistake I'm overlooking?

The lack of strictures.
The lack of warnings.
The lack of providing the system error message in the "open || die"
construct.
The lack of a valid description of "not working"

Paul Lalli
 
B

Brian McCauley

DMB said:
I have a Perl script that serves a PDF on a Unix server and it works
perfectly. The same script on Windows is not working. Can someone
tell me what obvious mistake I'm overlooking?

Yes, you are posting to comp.lang.perl.misc and the total sum of the
description you give of the undesired behaviour you are observing is
"not working".

Obvious mistakes like this can be avoided by consulting the posting
guidelines for this group.
 
D

DMB

I guess that means, in short, that you don't see anything wrong with
the code.

Thanks, I didn't think it was wrong either.
 
A

Anno Siegel

Please give an attribution and quote some context.
I guess that means, in short, that you don't see anything wrong with
the code.

No, it means Brian didn't bother to criticize code so ineptly presented.
There's plenty wrong with it.
Thanks, I didn't think it was wrong either.

In German, we have an expression for what you're doing: "Du lügst dir in
die eigene Tasche".

Anno
 
A

A. Sinan Unur

[ Please provide some context when you post.
The time for reading the posting guidelines was yesterday.
]

The lack of strictures.
The lack of warnings.
The lack of providing the system error message in the "open || die"
construct.
The lack of a valid description of "not working"

I guess that means, in short, that you don't see anything wrong with
the code.

Thanks, I didn't think it was wrong either.

That attitude will not get you anywhere. Here is your original post:

I have a Perl script that serves a PDF on a Unix server and it works
perfectly. The same script on Windows is not working. Can someone
tell me what obvious mistake I'm overlooking?

Here are the obvious mistakes you are overlooking:

1. You either did not look in the server log or did not provide the
information. Lacking ESP capabilities, we cannot help you. Don't post if
you don't want help.
#!c:/Perl/bin/Perl.exe

print "Cache-control: no-cache\n";
print "Content-type: application/pdf\n\n";
open (CODE, "C:/Program Files/Apache
Group/Apache2/htdocs/mp/corr/notfound.pdf") || die;

2. You call die with no arguments.

use File::Spec::Functions 'catfile';
my $fn = catfile $ENV{DOCUMENT_ROOT}, 'mp', 'corr', 'notfound.pdf';
open my $pdf, '<', $fn or die "Cannot open $fn: $!";
binmode STDOUT;
binmode CODE;
print <CODE>;
close (CODE);
exit;

3. There is no point to this exit call.

4. We don't know if you script is even called by Apache. You have
provided no information on the HTTP status code.

5. "Does not work" does not work.

Sinan.
 
S

Shawn Corey

Anno said:
In German, we have an expression for what you're doing: "Du lügst dir in
die eigene Tasche".

Anno

OK, what does it mean? I ran it thru Google's translation tool and got,
"You lie yourself into the own bag." Something is lost in the translation.

--- Shawn
 
A

Anno Siegel

Shawn Corey said:
OK, what does it mean? I ran it thru Google's translation tool and got,
"You lie yourself into the own bag." Something is lost in the translation.

It's about as good as mechanical translation can get. "You are lying into
your own purse" would come closer. As popular sayings do, it doesn't quite
conform to regular grammar -- you can't lie "into" something, not even in
German. The idea is for someone to exaggerate the amount of cash they own,
but again typical for popular sayings, the literal meaning doesn't quite
cover the range of situations it would be used in. It is said when someone
is grasping for aspects that make their situation seem more favorable than
it really is. "I'm sure the red light hasn't been on for long. We'll
make it!" -- "Du lügst dir doch in die eigene Tasche".

Anno
 
A

Alan J. Flavell

ist ja idiomatisch...
It's about as good as mechanical translation can get.

"You're only fooling yourself" would, I think, be as near as we need
in this context.
 
A

Anno Siegel

l v said:
Anno

While I am accustom to working with a German written software, Google
had a hard time translating to English.

"Du lügst dir in die eigene Tasche" = "You lie yourself into the own bag"

See the lengthy explanation elsewhere in the thread. MYEWTK


Anno
 
A

Anno Siegel

l v said:
Anno

While I am accustom to working with a German written software, Google
had a hard time translating to English.

"Du lügst dir in die eigene Tasche" = "You lie yourself into the own bag"

See the lengthy explanation elsewhere in the thread. MTYEWTK


Anno
 
R

Rene Schickbauer

DMB said:
I have a Perl script that serves a PDF on a Unix server and it works
perfectly. The same script on Windows is not working. Can someone
tell me what obvious mistake I'm overlooking?

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

print "Cache-control: no-cache\n";
^^^^^^^^^^^^^^^^^^^^^

This does NOT work very well with IE (haven't really checked the rest of
your script because the above line will surely make trouble on IE6).

I had some problems with that, both serving from PHP and Perl.

The reason seems to be that IE downloads the file, deletes it from the Cache
and simultaniously calls Acroread.

The problem depends on client *and* server timing.

Here's the Header-generating code i used in a PHP project (converting it to
perl is up to the user):

---

// Send special headers
// See http://at.php.net/en/session_cache_limiter for details
//header("Pragma: no-cache"); <-- Bug in IE triggers deletion of temporary
// file before opening

header("Content-Type: application/pdf");
$pdfid = "$filename-$timestamp.pdf";
header("Content-Disposition: inline; filename=$pdfid");
//header("Accept-Ranges: bytes");
//header("Expires: 0");
//header("Cache-Control: private");

---

If left the comments in to show what is and what isn't working. Make sure
the filename always changes. I did this by adding a timestamp to the
filename.

LLAP & LG
Rene
 
B

Big and Blue

Rene said:
^^^^^^^^^^^^^^^^^^^^^

This does NOT work very well with IE

A common problem...
The reason seems to be that IE downloads the file, deletes it from the Cache
and simultaniously calls Acroread.

Sounds similar to a view I reached recently over similar things.

Basically, IE has several bugs like this which make it unreliable.
 

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

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,085
Members
48,773
Latest member
Kaybee

Latest Threads

Top