Solved

sh or bash cgi

Posted on 1997-12-21
4
614 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now