[CGI1.05] CGI scripts fail with 'exec format error'

A CGI script must begin with a valid 'interpreter line' also called 'shebang'. That must be the first line in the file and must start in the first column. It should begin with the two characters '#!', followed by a path to an interpreter, followed by any options.

For example:

#!/usr/bin/php

will run the script through the PHP interpreter at /usr/bin/php.

#!/usr/bin/perl -w

runs the script through /usr/bin/perl with the -w flag to enable warnings.

An 'exec format error' is the result of an invalid interpreter line. That could be because the interpreter line is missing, or indented with a tab, for instance.

Was this answer helpful?

 Print this Article

Also Read

[CGI1.02] My CGI/Perl scripts are failing with error 500 (Internal Server Error)

These errors are nearly always related to a coding error within the script, or bad variables...

[CGI1.01] My CGI/ASP/PHP script is giving an error when trying to write to a file.

This applies to Linux hosting accounts only.This is almost certainly down to incorrect...

[CGI1.09] I've created a cgi-bin inside my public_html folder, placed my script into it and yet it can't be found. Why?

The 'cgi-bin' is a protected folder name and will always point to the cgi-bin in the root of the...

[CGI1.06] Accesses to all files result in '500 Internal Server Error' messages

500 Internal Server Error messages on every page are typically an indication of a misconfigured...

[CGI1.07] Why is my scheduled task (CRON job) not running?

If the scheduled task did not run check the following before contacting support.1) The file...