Reputation: 11
All my perl programs have suddenly produced 500 errors when executed in the cgi-bin of a website. They were working fine last week.
When executing from the command line "perl program.pl" works correctly. However when any program is executed with paremeters eg "perl program.pl?param1=xxxx" I get "No such file or directory"
It looks as though Perl or the system is seeing the program & parameters as the filename and not parsing the part before the '?'. I have changed nothing but I did have a crash this week which may have disrupted perl in some way. But I have no idea where or what to look for.
Perl is running under Debian Jessie on an ISPConfig setup. PHP is working just fine. File permissions are ok (or I wouldn't be able to execute the bare program).
Upvotes: 1
Views: 2574
Reputation: 69274
In addition to ikegami's excellent answer, it's worth pointing out that if your CGI programs are written using CGI.pm, then they already have built-in support for running them on the command line for debugging purposes. You just need to to omit the ?
in your call.
perl program.pl param1=xxxx
This passes the parameter param1=xxxx
to your program and CGI.pm will simulate that information being passed in through a standard CGI environment.
Upvotes: 0
Reputation: 385897
However when any program is executed with paremeters eg "
perl program.pl?param1=xxxx
" I get "No such file or directory
".
As you should, and as it always has been.
perl
is used to execute Perl scripts. As such, it needs to be provided the path to a Perl script. There's no reason for it to accept URLs. Arguments to pass to the Perl script can be passed as additional arguments to perl
.
$ cat >script.pl
print "Received ".( 0+@ARGV )." arguments.\n";
print "$_: $ARGV[$_]\n" for 0..$#ARGV;
^D
$ perl script.pl abc def
Received 2 arguments.
0: abc
1: def
Perhaps you are trying to execute a Perl script as a CGI script. That would require actually obeying the CGI protocol when launching Perl, something you aren't doing. The most common way of doing that is to launch it via a web server, the intended parent of a CGI program.
All my perl programs have suddenly produced 500 errors
The first thing to do is check the web server's error log to see what error is causing the web server to return an error.
Upvotes: 4