LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   form data as $1, shell script & cgi (http://www.linuxquestions.org/questions/programming-9/form-data-as-%241-shell-script-and-cgi-891529/)

haiders 07-13-2011 02:24 PM

form data as $1, shell script & cgi
 
I have a form page custlookup.html:

Code:

<html>
<head>
<title> Forms </title>
</head>
<body>
<FORM METHOD="POST" action="http://192.1.1.1:83/cgi-bin/scopelookup.sh">
Choose your option
<br>
Enter device name  <INPUT TYPE="TEXT" NAME="devid" SIZE=20 MAXLENGTH=25>
<p><br>
<INPUT TYPE="Submit" NAME="Submit This Form">
<INPUT TYPE="Reset" NAME="Clear">
</FORM>
</body>
</html>

I would like to be able to take the input (devid) provided in the form on the webpage and execute the script scopelookup.sh with the devid appended as the case.
Should execute as follows on the server:

% ./scopelookup.sh $devid

I tried appending the method with the $devid but that doesn't seem to work:
Code:

<FORM METHOD="POST" action="http://192.1.1.1:83/cgi-bin/scopelookup.sh $devid">
Unfortunately, I'm not a developer, web page designer, or scriptor so your explanation in laymans terms is appreciated.

Tinkster 07-13-2011 03:28 PM

Try modifying the script to use FORM_devid rather
than passing variables to the script. (Assuming you're
using proccgi).


Cheers,
Tink

P.S.: Moved to PROGRAMMING.

haiders 07-13-2011 03:58 PM

Thanks for the reply Tinkster. I wasn't aware of proccgi until you mentioned it. I just googled it and it appears to be a variable translator from web form to shell scripts which appears to be exactly what i need. But as I mentioned my scripting skills are joke worthy so I have some basic questions for you:
1 - how do I determine if proccgi is installed on the server?
2 - how can I troubleshoot my issues since monitoring the error.log in apache doesn't seem to provide any errors. I'd like to see what variable if any the script is taking so that I may attempt to correct it.

With the current config i get the following one liner result on my web page:

Usage: scopelookup.sh

theNbomr 07-13-2011 07:38 PM

I think simply using HTTP GET rather than POST will cause the web server to pass arguments via the CGI commandline, rather than STDIN. Your CGI will get arguments from all form elements, and they will be of the form "?key1=value1&key2=value2&...." You should be able to parse out the key/value pairs in your script, especially since your list of form elements appears to be small.

--- rod.


All times are GMT -5. The time now is 07:45 PM.