bad interpreter: No such file or directory when running perl script on OS X


I found a perl script that refused to run on Max OSX. I would consistently get:

#: bad interpreter: No such file or directory

This link set me on the right direction by suggesting that there were DOS CR characters in the file rather than the *nix LF, but his suggestion didn’t work for me. Instead, I used vim to create a new file and copied the text from a text editor, and simply pasted it into vim.

A bit crude, but it worked for me

Command summary:

vim newfile
<esc>:i <now paste>
<esc>
:wq

About RedNectar Chris Welsh

Professional IT Instructor. All things TCP/IP, Cisco or Data Centre
This entry was posted in Mac OS X, perl. Bookmark the permalink.

2 Responses to bad interpreter: No such file or directory when running perl script on OS X

  1. If you’ve already got vim open, you can convert the line endings with :set fileformat=unix in command mode.
    Or use any of the (perl|sed|awk|$whathaveyou) oneliners 🙂

    • rednectar says:

      Sorry Marko but the command :set fileformat=unix did absolutely nothing when I tried it. Maybe using a different version of OS X (I’m using 10.6.5)

Comments are closed.