"bad interpreter" error

L

linziheng

Hi all,

I use vim to create a perl file, change its permission to executable,
and then type "./myfile.pl" to run it, but i got the following error

: bad interpreter: No such file or directoryl

The first line of the file is pointing correctly to my perl. And when i
run "perl myfile.pl", it runs happily. I dont know what's going wrong.
Is it something wrong with my vim?

Thank you!
 
J

John W. Krahn

I use vim to create a perl file, change its permission to executable,
and then type "./myfile.pl" to run it, but i got the following error

: bad interpreter: No such file or directoryl

The first line of the file is pointing correctly to my perl. And when i
run "perl myfile.pl", it runs happily. I dont know what's going wrong.
Is it something wrong with my vim?

The first two bytes of the file have to be '#!' followed by the absolute path
to perl so that the OS can find it, for example:

#!/usr/bin/perl



John
 
P

Paul Lalli

I use vim to create a perl file, change its permission to executable,
and then type "./myfile.pl" to run it, but i got the following error

: bad interpreter: No such file or directoryl

The first line of the file is pointing correctly to my perl.

..... so you think, anyway.
And when i
run "perl myfile.pl", it runs happily. I dont know what's going wrong.
Is it something wrong with my vim?

I've never used vim, so I can't answer that. However, I see this error
all the time when people write their files in Windows and then transfer
it to unix. You get an additional non-printing character on the end of
each line, and therefore your shebang is actually pointing to
"/usr/bin/perl\r", which doesn't exist.

Try running dos2unix on your file, and see what happens after that.

Paul Lalli
 
L

linziheng

Hi,

Your guessing is totally correct. I set the fileformats in vim to
support dos format. When i turn it off, the error is gone.

Thanks a lot for your suggestion!
 
T

Tad McClellan

and then type "./myfile.pl" to run it, but i got the following error

: bad interpreter: No such file or directoryl

The first line of the file is pointing correctly to my perl.


No it isn't.
 
F

fishfry

Hi all,

I use vim to create a perl file, change its permission to executable,
and then type "./myfile.pl" to run it, but i got the following error

: bad interpreter: No such file or directoryl

The first line of the file is pointing correctly to my perl. And when i
run "perl myfile.pl", it runs happily.

That's a clue. Clearly your #! line isn't correct. FWIW if you happen to
have an invisibile DOS line terminator at the end of your #! it causes
an error like that. Could that be the problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top