Trying to submit web form content to a shell script

Hi I was hoping some one could help me with a problem I have.
I am trying to collect some information from a web form and save it to a text file.
I found an example on this site that is sort of what I am trying to accomplish, the shell script bellow should echo the input back to the browser but I dont seem to be able to make the example scripts and form work on my system. I am working on a mac running El Capitan 10.11.6.

The example uses the korn shell but I have change it to bash on my system.

the code for the form is

<html><head><title>Test Form</title></head>
<body>
  <form action="/cgi-bin/test.cgi" method="get">
    input for GET: <input name="get_input">
    <input type=submit value="Submit via GET">
  </form>
  <form action="/cgi-bin/test.cgi" method="post">
    input for POST: <input name="post_input">
    <input type=submit value="Submit via POST">
  </form>
  </body>
</html>
 

the code for the shell script is

#!/bin/ksh
 print "Content-type: text/plain\r\n\r"
print "my query string from (GET) is \"$QUERY_STRING\""
print "\nmy stdin (from POST) is"
cat

I get a couple of different errors when I submit the form through my browser
one is

Forbidden
You don't have permission to access /test.cgi on this server.
Apache Server at 192.168.5.122 Port 80

or

Not Found
The requested URL /cgi-bin/test.cgi was not found on this server.
Apache Server at 192.168.5.122 Port 80

I have tried placing the test.cgi script in the same directory as my html page and and I get the permissions error. When I move the test.cgi script to my /Library/WebServer/CGI-Executables folder and point the form action towards that folder I get a 404 error.
Do I need to change anything in Apache to be able to run cgi scripts?
All I want to do is collect the form data to a text file and without having to use php or python.
If I was able to accomplish this with perl or awk or any shell program that would be great.
I would be very grateful for any help you could give me with this problem.