Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

bad interpreter: No such file or directory

by carric (Beadle)
on Jan 20, 2004 at 07:56 UTC ( #322531=perlquestion: print w/ replies, xml ) Need Help??
carric has asked for the wisdom of the Perl Monks concerning the following question:

I am stumped.. I have a script for which I have verified perl is indeed where it should be, but if you execute it like this:

./script.pl

it gives the message

: bad interpreter: No such file or directory

IF you go into the script and change

#!/usr/bin/perl
to
#!/usr/bin/perl -w

It executes.. but there are SO many errors, it doesn't work (it's a CGI script from somebody, that has "issues").

Has anyone ever seen this?? It has some "require" statements for some other perl chunks, and I was wondering if that had anything to do with it, but I edited a few scripts, and it doesn't seem to affect anything.

The script lives on a local file system, and has proper permissions.

Thanks a lot ahead of time.

Update:

I did not see any control chars, but ran dos2unix anyway on it, and then it started working. Really strange.

Thanks everyone!!

Comment on bad interpreter: No such file or directory
Re: bad interpreter: No such file or directory
by BazB (Priest) on Jan 20, 2004 at 08:08 UTC

    Check for control characters on the end of the lines - normally caused by copying scripts from one platform to another without correcting the line endings.


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

      Thank you... It saved a lot of time for me.
Re: bad interpreter: No such file or directory
by cchampion (Curate) on Jan 20, 2004 at 08:38 UTC
Re: bad interpreter: No such file or directory
by dws (Chancellor) on Jan 20, 2004 at 08:56 UTC
    If you FTP in binary mode (or otherwise copy) from a Win32 box to a box that's some variant of Unix, you have an invisible hidden carriage return (^M) at the end of each line. The "bad interpreter" that's being referred to in this case is   /usr/bin/perl^M
    Copy the file in ASCII mode, or use dos2unix (or the equivalent), and your problem will probably go away.

      Or just make sure you have spaces after /perl, something like #!/usr/bin/perl -w  -  
      or use dos2unix (or the equivalent)
      Or of course use perl with the p and i switches.. perl -pie's/\r\n/\n/g;'
Re: bad interpreter: No such file or directory
by Ophidions (Initiate) on Nov 10, 2011 at 10:13 UTC
    This happens when executing scripts with a different line endings pattern different to that of the system you are running. Since it seems you are running on a linux system, open your script in an editor like geany then convert line endings to unix style. This is also encountered with apache. Regards.
      I ran into this same issue. Thanks for the help. It worked after removing the ending characters. I wrote my pl script in Notepad++ (windows), which was causing it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://322531]
Approved by BazB
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-07-12 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls