Some Perl cgi scripts are not working: (2)No such file or directory: exec failed

Created:

2017-05-10 05:05:06 UTC

Modified:

2017-08-08 13:27:58 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Some Perl cgi scripts are not working: (2)No such file or directory: exec failed

Issue Symptoms

Some Perl CGI scripts are not working, 500 Internal Server Error occurred.

In /var/log/httpd/suexec_log the following can be found:

uid: (10005/testdomain) gid: (1003/1003) cmd: lala_copy.cgi [2017-05-10 11:58:08]: (2)No such file or directory: exec failed (lala_copy.cgi) End of script output before headers: lala_copy.cgi

Under domain /var/www/vhosts/system/testdomain.tld/logs/error_log the following appeared:

End of script output before headers: lala_copy.cgi

Conditions

Script was copied to the server in non ASCII.

End-of-line characters exist.

Resolution

Check that there are no any end-of-line characters like ^M:


# vim -b /var/www/vhosts/testdomain.tld/httpdocs/cgi-bin/lala_copy.cgi
#!/usr/bin/perl^M
print "Content-type: text/html\n\n";^M
print "Hello, User1.";^M

Remove them if needed.

Please note that according to apache documention end-of-line characters cannot be recognized by apache:

When editing CGI scripts on Windows, end-of-line characters may be appended to the interpreter path. Ensure that files are then transferred to the server in ASCII mode. Failure to do so may result in "Command not found" warnings from the OS, due to the unrecognized end-of-line character being interpreted as a part of the interpreter filename.

 

Have more questions? Submit a request
Please sign in to leave a comment.