Hi, Yes, you've confirmed my diagnosis: when I tested by sending a script from my Windows machine to a Linux machine in binary transfer mode (failing to convert line endings), and executed it as a CGI script, my browser told me I have an internal server error, and my apache error log told me I've had a "premature end of script" error. That's the sort of error you see, when the script terminates before the HTML header is output. I tested without the -w switch first. When I added back in the -w switch, all was ok. There is a reason for that; without the -w switch, the operating system thinks your shebang line is requesting /usr/bin/perl\r (perl\r being an invalid command name).

The point being, that my assessment of your problem is probably accurate. If you are, as you say, transferring in ascii mode, and line endings are still failing to be converted, that's an additional problem with your FTP or PSFTP software. I'd check into that. But in the meantime, get into the habbit of, immediately following your file transfer, executing "dos2unix filename.cgi" on your remote server. It's as important as remembering to set file permissions.

Humor us and try the dos2unix program to convert your line endings.


Dave


In reply to Re: Re: Re: #!/usr/bin/perl by davido
in thread #!/usr/bin/perl by emilio_ayllon

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.