Trying to submit web form content to a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to submit web form content to a shell script
# 1  
Old 05-31-2018
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
Code:
<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
Code:
#!/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
Code:
Forbidden
You don't have permission to access /test.cgi on this server.
Apache Server at 192.168.5.122 Port 80

or
Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exec submit form in bash script

Hi All, I'm new in forum. Many congratulations to everyone for all work. I'm not an expert in bash script I've a problem with a sh file. The sh file run every t minuts and it read data from txt file and then compile form. Finally, the user, from the web browser click on send. The script... (0 Replies)
Discussion started by: Herbert
0 Replies

2. Programming

Html form to submit data to bash script

hi all, im going to design a web html form so users can input what username and password they want to make the ftp account, once they enter in a username and password they click on the submit button and it submits it to a bash script and then the bash script will run and finish of making the... (3 Replies)
Discussion started by: robertkwild
3 Replies

3. Web Development

Apache2 web application- Submit button - write data into a file

Hello, I am newbie on php-mysql and just know only installation. I have an apache2+php5+mysql installed VPS. What I would like to do is that when visitor enters requested data shown in index.html, submit button will run a script to save each field into a file. Here is an example shown in... (1 Reply)
Discussion started by: baris35
1 Replies

4. UNIX for Dummies Questions & Answers

How to submit form on an php webpage from command line?

Hello, i have page domain.com/form.php the form fields on form.php are named: name=ipaddress name=port and submit button is named: submit i want to ask how the linux command will look like to submit the form filled with: ipaddress: 127.0.0.1 port: 80 I tried various curl and... (5 Replies)
Discussion started by: postcd
5 Replies

5. Shell Programming and Scripting

Can't submit a form.

hello my script is submitting POST-data to a site (its not my first script, i've done these before many times (include parsing scripts) but this one is tough) so the problem is i'm submitting a form with firefox and in firebug i see WHAT exactly i'm submitting then when i do EXACTLY the... (28 Replies)
Discussion started by: tip78
28 Replies

6. Shell Programming and Scripting

Using cURL to submit a post form

I am trying to write a shell script to use curl in order to automate downloading data from a website. The URL with the post form is here: http://try-db.org/de/InfoBySpecies.php . I have a list of about 1800 different species I want to check. For Example, choose the first species and use the... (2 Replies)
Discussion started by: hansvg
2 Replies

7. Shell Programming and Scripting

Pass values from web form to shell script

Hi, is it possible to pass more values from web form like textbox to shell script and if yes,how to do that.:confused::confused::confused: (2 Replies)
Discussion started by: tdev457
2 Replies

8. Shell Programming and Scripting

Filling out Web Form from Script

I am trying to fill out a web form from within a script I am writing. I think that I should be using curl to do this, but I'm not really sure. The form has username and password fields and a submit button. I want to be able to log in from the command line. Html from the site: <h5... (2 Replies)
Discussion started by: vockleya
2 Replies

9. Shell Programming and Scripting

using wget to submit a form on linksys router

I'm trying to use wget to submit a form. I have tried to dig out what is actually being "posted" and where, using tamperdata (see below). http://ubuntuforums.org/attachment.php?attachmentid=109123&d=1239224127 Here is my wget command: wget --http-user=xyz --http-password=xyz... (1 Reply)
Discussion started by: mike909
1 Replies

10. Shell Programming and Scripting

PHP Help with Form Submit

Hi, I have a custom HTML form that has a couple radio buttons and a text field that requires a number. I'm not a php programmer and could use some help with putting together php code to calculate a total based on the radio button selection and the text field number. ... (3 Replies)
Discussion started by: nck
3 Replies
Login or Register to Ask a Question