Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

something wrong when I exec a script with perl (ubuntu10.10)

Tags:

bash

ubuntu

perl

I got a perl script named test_perl.pl and try to exec it.
The first line of the scrpit is:

#!/usr/bin/perl

When I try to exec this script, I get an error.

$ type perl
perl is /usr/bin/perl

$ ll /usr/bin/perl test_perl.pl
-rwxr-xr-x 2 root        root        10352 2011-04-23 03:32 /usr/bin/perl*
-rwxr-xr-x 1 jim         jim         12121 2013-11-21 11:47 test_perl.pl*


$ test_perl.pl
test_perl.pl: line 1: #!/usr/bin/perl: No such file or directory

I don't no why this happens.

like image 840
android_su Avatar asked Nov 24 '25 13:11

android_su


1 Answers

You have a BOM (see http://en.wikipedia.org/wiki/Byte_order_mark) at the beginning of your file.

try

 xxd test_perl.pl

to see it. Getting rid of the BOM will fix your script: Lots of ways to do this: Using awk to remove the Byte-order mark

like image 200
Faiz Avatar answered Nov 26 '25 18:11

Faiz