質問

I am using perl 5.10.1 and the path to perl is /usr/bin/perl

I've chmoded the file to 755 and I am getting an internal server error:

#!/usr/bin/perl
use strict;

print "Content-type: text/plain\n\n";
print "huh";

The code is so simple, I have no idea what's causing this. I am also running a forum software that was coded in Perl and it works fine and uses the same path.

edit: Thanks for everyone's help, I created another folder and added a cgi-bin in there and tried the script, it works. I still have no idea why it wouldn't work in the first one, a bud edited my .htaccess file in the first folder that could be the problem.

役に立ちましたか?

解決

Note that the correct spelling is Content-Type.

There may be a problem with buffering (the output amount is small, there is no newline at the end etc ...) It just makes me suspicious. This is the minimal script I would try:

#!/usr/bin/perl

use strict;
use CGI qw(:standard);

local $| = 1;

print header('text/plain'), "huh\n";

Did you FTP the file from a Windows PC to a Unix system? If you transferred the file in binary mode, the shebang line will not be correct.

For example:

$ unix2dos t.pl
unix2dos: converting file t.pl to DOS format ...
$ xxd t.pl
0000000: 2321 2f75 7372 2f62 696e 2f70 6572 6c0d  #!/usr/bin/perl.
0000010: 0a0d 0a70 7269 6e74 2022 4041 5247 565c  ...print "@ARGV\
0000020: 6e22 3b0d 0a                             n";..
$ ./t.pl hello world
zsh: ./t.pl: bad interpreter: /usr/bin/perl^M: no such file or directory
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top