Solved

sh or bash cgi

Posted on 1997-12-21
4
617 Views
Last Modified: 2013-12-26
I'm designing a high school web page and i would like to add a student poll with 5 radio buttons.  I would like the cgi script to use a select case to determine which choice was not null.  I need help on the code for shell script, like how do i parse input from the html form like i can in Perl with the cgi-bin.pl library?  I need to be able to assign a varible to each 'name' element in the form. Please help me.  Thank you for your help.
0
Comment
Question by:alphamorgan
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1295833
#!/bin/sh
echo Content-type: text/plain
echo
if [ "$REQUEST_METHOD"  =  "POST" ]
then
read QUERY_STRING
fi
case $QUERY_STRING in
*radio=button1*) echo button1 was selected;;
*radio=button2*) echo button2 was selected;;
*radio=button3*) echo button3 was selected;;
*radio=button4*) echo button4 was selected;;
*radio=button5*) echo button5 was selected;;
esac
for name in `echo $QUERY_STRING | tr '&' ' '`
do
echo $name
#this only works if your form variables are named like sh variables
eval $name
done
set
0
 
LVL 84

Expert Comment

by:ozo
ID: 1295834
But I should warn you that the
eval $name
could be dangerous if your script is called with something like
http://cgi.sh?/usr/bin/rm*.*
so you should really validate your input first.
0
 

Expert Comment

by:grantk
ID: 1295835
The biggest danger with CGI shell-scripting is the security.
Why can't you use perl with the -T option?
0
 

Accepted Solution

by:
mikal120797 earned 100 total points
ID: 1295836
You should be able to find all the sample scripts that you need, as well as possibly one to do just what you want (why reinvent the wheel?) at the following URL:

http://www.yahoo.com/Computers_and_Internet/Internet/World_Wide_Web/CGI___Common_Gateway_Interface/
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 106
unable to delete all specified values regedit 38 547
firstChar challenge 13 121
Way to decrease size of apk file 9 86
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question