-3

I am studying HTML and CGI. I installed Apache on the ubuntu server, it works fine as I can see the test pages. I put a new webpage that calls a sample Hello world script from /usr/lib/cgi/ bin folder but when I run it I get this error:

Not Found
The requested URL /usr/lib/cgi-bin/save_file.py was not found on this server.

Access rights for the /usr/lib/cgi-bin are all set to root:root and the permissions for the script are a+x.

The HTML file content is as following (taken from one of the samples online):

enctype="multipart/form-data" action="/usr/lib/cgi-bin/save_file.py" method="post"

(I had to remove HTML tags from here as they do not upload correctly but this is the relevant part)

Anybody has any idea why my script - save_file.py is not found?

Jon7
  • 7,165
  • 2
  • 33
  • 39
Nik
  • 1
  • 4

1 Answers1

0

Use action="/cgi-bin/save_file.py" instead.

In the case of a URL, the root (/) is the root of your webserver, which is set up to be /var/www. It would be quite dangerous for your HTML pages to have access to your root directory, no? Imagine the consequences of allowing action=/bin/rm.

The default configuration of Apache automitically makes /cgi-bin point to /usr/lib/cgi-bin.

David Cain
  • 16,484
  • 14
  • 65
  • 75
  • Hi David, tanks for your answer but It does not work as well. What happens is that it shows me the following error - can not access /config/cgi-bin/save_file.py. So it seeks the file inside my current test website folder and not inside /usr/lib/cgi-bin... – Nik Nov 02 '12 at 19:22
  • Where is `/config/cgi-bin/save_file.py` coming from? – David Cain Nov 02 '12 at 19:25
  • Make sure the action is `/cgi-bin/...` as opposed to `cgi-bin/...`. – David Cain Nov 02 '12 at 19:27
  • I wrote some hello-world script. The message comes when I open the index.html that is located inside the subfolder of - /var/www/config/index.html in the browser. – Nik Nov 02 '12 at 19:31