funkymonkey has asked for the wisdom of the Perl Monks concerning the following question:

I know this kind of deals maybe not so much with perl fully, but more of the system. However, I am asking this question in hope that someone has had this problem before.

On my system running perl v5.8.3 I have come across an odd problem:

The script in question:

$ ./test1.pl

: bad interpreter: No such file or directory

$

The second script that works:

$ ./test2.pl

Usage: do this, do that.

$

Now, both of the scripts both include #!/usr/bin/perl in the beginning of the script. They also are set with the same permissions and everything. What could be this problem, I know it doesn't deal with perl coding, however, once again, I was just wondering if maybe someone has run into this problem before.

Help would be appreciated, thanks!

Replies are listed 'Best First'.
Re: Problem with perl interpretor
by saskaqueer (Friar) on Jan 09, 2005 at 04:54 UTC

    You've most likely got an issue with your line endings. What would be happening is that you've got a carriage return at the end of the first line, so *nix is looking for a binary at "/usr/bin/perl\r" instead of the correct "/usr/bin/perl". Try running this one-liner on the file by replacing 'foobar.qux' with the name of your file, and then try running the perl script again.

    $ perl -pi -e 's/\r\n/\n/;' foobar.qux
      Worked great. Thanks! Since I didn't it locally on the system, must have *somehow* grabbed a carriage return when transfering it from the jumpdrive to the disk.

      Thanks again.

Re: Problem with perl interpreter
by brian_d_foy (Abbot) on Jan 09, 2005 at 06:50 UTC
Re: Problem with perl interpreter
by vek (Prior) on Jan 09, 2005 at 07:25 UTC

    Other monks have given you some good advice about line endings but I've seen the 'bad interpreter' message reported by the bash shell on a Solaris box - it was purely a permissions problem:

    $ ls -l foo.pl -rw-r--r-- 1 user group 44 Jan 9 00:05 foo.pl $ ./foo.pl bash: ./foo.pl: bad interpreter: Permission denied $ chmod 755 foo.pl $ ls -l foo.pl $ -rwxr-xr-x 1 user group 44 Jan 9 00:16 foo.pl $ ./foo.pl $ Hello World $
    -- vek --