The file was created on a non-Linux system and uploaded without converting line endings, or if you created the file on your linux system, the editor was in the wrong line-ending mode. Also, isn't the message "/usr/bin/perl^M: bad interpreter: No such file or directory"? It's really important to post complete error messages, as something that might seem irrelevant to you may provide insight into problem that others who are accustomed to seeing error messages can better decipher. After all, if you understood what parts of the message were important you wouldn't need to ask, right? ;)

In this thread, "/usr/bin/perl^M: bad interpreter:", I really like the statement, "The ^M is the key to the entire problem, it's not something that just can be ignored."

What that message is really telling you is that your operating system cannot find an interpreter named /usr/bin/perl^M. Windows and DOS terminate text lines with carriage-return (ASCII 13), followed by line-feed (ASCII 10). Linux uses just line-feed to terminate lines. So the shell knows that when it sees #!/usr/bin/perl^J, where ^J is the ASCII-10 line feed at the end, that line feed character can be stripped away from the text, and it can go looking for an interpreter named /usr/bin/perl.

But in your case, your shell is finding #!/usr/bin/perl^M^J (ASCII 13, ASCII 10 at the end of line), it again gladly ignores the linefeed, but thinks that you are looking for a program named #!/usr/bin/perl^M, where "^M" represents ASCII 13, the carriage return character. It's unlikely that you have a Perl interpreter named perl^M, and since you don't, your shell complains to you.

There are utilities that can convert DOS/Windows line endings to Linux line endings. Also FTP clients, in "text" mode will handle the conversion for you silently. And some editors can be configured to generate output with linefeeds as line terminators even when edited on carriage-return/line-feed operating systems. The easiest mechanism is to just set your FTP client to do the conversions for you. ...or develop in an environment that matches your target deployment operating system.


Dave


In reply to Re: executing perl script by davido
in thread executing perl script by sindicalista

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.