LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-13-2011, 01:24 PM   #1
haiders
Member
 
Registered: Sep 2006
Posts: 62

Rep: Reputation: 15
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.
 
Old 07-13-2011, 02:28 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
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.
 
Old 07-13-2011, 02:58 PM   #3
haiders
Member
 
Registered: Sep 2006
Posts: 62

Original Poster
Rep: Reputation: 15
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
 
Old 07-13-2011, 06:38 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.

Last edited by theNbomr; 07-13-2011 at 06:42 PM.
 
  


Reply

Tags
cgi, cgibin, method, shell script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C & kernel data structure & shell script vishalbutte Programming 7 01-13-2006 08:38 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
Script to get form data..in bash? jrfly Linux - General 1 06-29-2005 10:04 AM
shell script works form command line but not form crontab saifee General 1 10-14-2004 10:27 AM
shell script form submit precioso77 Linux - General 2 05-18-2003 11:50 AM


All times are GMT -5. The time now is 12:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration