Solved

sh or bash cgi

Posted on 1997-12-21
4
620 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

690 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