Problem serving a PDF

Discussion in 'Perl Misc' started by DMB, Feb 1, 2005.

  1. DMB

    DMB Guest

    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;
     
    DMB, Feb 1, 2005
    #1
    1. Advertising

  2. DMB

    Paul Lalli Guest

    "DMB" <> wrote in message
    news:...
    > 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

    <Code below for reference>


    > #!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;
    >
     
    Paul Lalli, Feb 1, 2005
    #2
    1. Advertising

  3. DMB wrote:

    > 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.
     
    Brian McCauley, Feb 1, 2005
    #3
  4. DMB

    DMB Guest

    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.
     
    DMB, Feb 1, 2005
    #4
  5. DMB

    Anno Siegel Guest

    DMB <> wrote in comp.lang.perl.misc:

    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
     
    Anno Siegel, Feb 1, 2005
    #5
  6. [ Please provide some context when you post.
    The time for reading the posting guidelines was yesterday.
    ]

    "Paul Lalli" <> wrote in news:LdOLd.1695$g16.1410
    @trndny08:

    > "DMB" <> wrote in message
    > news:...
    >> 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"


    "DMB" <> wrote in news:1107281658.322045.280830
    @z14g2000cwz.googlegroups.com:

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

    "DMB" <> wrote in news:1107272622.545671.227400
    @z14g2000cwz.googlegroups.com:

    > 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.
     
    A. Sinan Unur, Feb 1, 2005
    #6
  7. DMB

    Shawn Corey Guest

    Re: [OT] What does it mean? (WAS: Problem serving a PDF)

    Anno Siegel wrote:
    > 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
     
    Shawn Corey, Feb 1, 2005
    #7
  8. DMB

    Anno Siegel Guest

    Re: [OT] What does it mean? (WAS: Problem serving a PDF)

    Shawn Corey <> wrote in comp.lang.perl.misc:
    > Anno Siegel wrote:
    > > 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.


    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
     
    Anno Siegel, Feb 1, 2005
    #8
  9. Re: [OT] What does it mean? (WAS: Problem serving a PDF)

    On Tue, 1 Feb 2005, Anno Siegel wrote:

    | Shawn Corey of unsympatico.ca wrote:

    > > OK, what does it mean?


    ist ja idiomatisch...

    > > 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're only fooling yourself" would, I think, be as near as we need
    in this context.
     
    Alan J. Flavell, Feb 1, 2005
    #9
  10. DMB

    Anno Siegel Guest

    l v <> wrote in comp.lang.perl.misc:
    > Anno Siegel wrote:
    > > In German, we have an expression for what you're doing: "Du lügst dir in
    > > die eigene Tasche".
    > >
    > > Anno

    >
    > 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
     
    Anno Siegel, Feb 2, 2005
    #10
  11. DMB

    Anno Siegel Guest

    l v <> wrote in comp.lang.perl.misc:
    > Anno Siegel wrote:
    > > In German, we have an expression for what you're doing: "Du lügst dir in
    > > die eigene Tasche".
    > >
    > > Anno

    >
    > 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
     
    Anno Siegel, Feb 2, 2005
    #11
  12. DMB wrote:

    > 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
     
    Rene Schickbauer, Feb 4, 2005
    #12
  13. DMB

    Big and Blue Guest

    Rene Schickbauer wrote:
    >>
    >>#!c:/Perl/bin/Perl.exe
    >>
    >>print "Cache-control: no-cache\n";

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

    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
     
    Big and Blue, Feb 5, 2005
    #13
    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. Alex Molochnikov
    Replies:
    11
    Views:
    2,710
    Mohun Biswas
    May 4, 2004
  2. Jeff Thies

    serving and downloading pdf's OT?

    Jeff Thies, Jan 29, 2004, in forum: HTML
    Replies:
    4
    Views:
    1,206
    Jeff Thies
    Jan 30, 2004
  3. phil
    Replies:
    13
    Views:
    656
    derek giroulle
    Jun 29, 2004
  4. Ricardo Pog
    Replies:
    1
    Views:
    444
    Austin Ziegler
    Mar 26, 2008
  5. Sean Nakasone
    Replies:
    1
    Views:
    391
    Farrel Lifson
    Apr 14, 2008
Loading...

Share This Page