I was trying to invoke a CGI program via an html file. But got stuck for the error "file not found".

I am trying the same program as in the following site:


Please find below the html file:

<html> <head>
<title>The Employee Database</title>
Appears on title bar
<h1> Employee Form </h1>
Appears in a large bold font
Adds a horizontal rule
<form action=”http://localhost/~ravbholua/emp_add.pl” method=get>
Emp-id: <input type=”text” name=”empid” size=4> <br>
Name: <input type=”text” name=”ename” size=30> <br>
Designation: <input type=”text” name=”desig” size=15> <br>
Department: <input type=”text” name=”dept” size=15> <br>
Dateoffuse: <input type=”text” name=”dtbirth” size=10> <br>
noSalary: <input type=”text” name=”salary” size=10> <br> <br>
<input type=submit value=”Add”>
The Add button is centered

To work in my system, I changed (changed than what is mentioned in the link above) the path of the CGI program file. The path is now: http://localhost/~ravbholua/emp_add.pl

When I click on Add button, I get error that 'file not found'. Please see attachment.

enter image description here

Please have a look at the form (attachment).

enter image description here

Why it is not finding the file which is in the home directory of username "ravbholua"? These 2 attachments w'd help you to catch the issue.

I have the same query in the below link but isn't resolved yet. Please look through it. http://www.linuxquestions.org/questions/linux-server-73/web-page-not-able-to-find-cgi-program-file-4175476182/

  • 1
    To be able to get help here your should really 1) give all the information you've given on the other site (no-one likes having to do cross-reference on the other site), 2) check the content and post here the HTTP server logs when you test the CGI, 3) fix the first link in the post and 4) fix the screenshots which are way too small to anyone to get anything from them.
    – zagrimsan
    Sep 15, 2013 at 14:57
  • The first guess, though, is that the script is not finding some of the files it refers to. Remember that HTTP servers usually restrict their content under the document root directory. However, it's just a wild guess without seeing the logs and the script (if you can post the script, it would make things much easier - if it's very long it might be enough to show the parts which open/read/write files).
    – zagrimsan
    Sep 15, 2013 at 14:59
  • By localhost/~ravbholua/ are you trying to access your $HOME? That won't work, you should have the perl script in the same directory tree as you place the HTML file.
    – terdon
    Sep 15, 2013 at 15:31
  • By the way - I want to view those screen shots, but they only show up as very tiny images on my browser - not sure if I'm missing the way to view them full size. Clicking on them had no effect.
    – ash
    Sep 16, 2013 at 6:10
  • Thank you @zagrism for showing me the mistakes. I have fixed the point no. 3 and ponit no. 4 of your 1st comment. That means: fixed the 1st link and fixed the 2 screenshots.
    – Ravi
    Sep 16, 2013 at 7:55

1 Answer 1


The web server doesn't typically translate ~ravbholua to your user home directory (it would take special configuration to make it do so), nor would I recommend attempting any method to get it to do so as that makes the entire contents of the home directory visible through the server - a major security risk.

Try creating a public_html directory under the home directory and place the file there. Note, though, that the web server may actually rewrite the location of CGI scripts, or refuse to treat a file at certain locations as CGI scripts - again, for security. It depends on the web server configuration. Likewise for the actual mapping of ~ravbholua - it may not go to that users $HOME/public_html directory.

Looking at the web server log file under /var/log, and probably named something like http.log or apache.log, may give errors or information that could help track down the root cause of this issue. If that doesn't work, tracing the web server using strace can help - although this can be tricky to do. The paths to all files accessed by the webserver can be seen via strace.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.