LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   HELP:write a CGI program with shell script (https://www.linuxquestions.org/questions/programming-9/help-write-a-cgi-program-with-shell-script-332693/)

supermyself 06-12-2005 04:55 AM

HELP:write a CGI program with shell script
 
Hi
I really need some help.

I intend to write a CGI program with shell script to read the input from forms.
I need this CGI program to test my web server designed myself,but ,unfortunately,I seldom know anything about CGI with shell script.There is not much time left for me.
Could any one help me,or could any one provide me with some materials about CGI with shell script?

Thx a lot.

Incidentally,html page source is:
<html><head>
<title>book.html</title>
</head>
<body>
<form name="form_example" method="post" action="/cgi-bin/book.pl">
First Name:<INPUT TYPE="TEXT" NAME="f_name"><BR>
Last Name:<INPUT TYPE="TEXT" NAME="l_name"><BR>
<BR>
Favorite Color:<BR>
<input type="RADIO" NAME="color" value="red">Red<BR>
<input type="RADIO" NAME="color" value="blue">blue<BR>

<input type="RADIO" NAME="color" value="green">Green<BR>
<input type="RADIO" NAME="color" value="yellow">Yellow<BR>
<BR>
Favorite Sport(s):<BR>
<input type="CHECKBOX" NAME="sports" value="football">Football<BR>
<input type="CHECKBOX" NAME="sports" value="baseball">Baseball<BR>
<input type="CHECKBOX" NAME="sports" value="basketball">Basketball<BR>
<input type="CHECKBOX" NAME="sports" value="golf">Golf<BR><BR>
<input type="SUBMIT" NAME="doit" value="Send Info">
</form>

</body>
</html>

marghorp 06-12-2005 08:10 AM

Re: HELP:write a CGI program with shell script
 
Quote:

Originally posted by supermyself
Hi
I really need some help.

I intend to write a CGI program with shell script to read the input from forms.
I need this CGI program to test my web server designed myself,but ,unfortunately,I seldom know anything about CGI with shell script.There is not much time left for me.
What exactly are you trying to do?

Write a CGI script or a shell script.

To just read a forms variables, use CGI.

What do you need shell scripting for?

Please give more information on what you are trying to acomplish.

supermyself 06-12-2005 09:10 AM

As you konw,CGI scripts could be written in several languages such as Perl,C,shell and so on.

1.I'd like to write a CGI program in shell script .

2.The CGI program could do the following:
a. reading data(such as 'f_name=supermyself&l_name=mxb&color=red&sports=basketball&doit=Send+Info') from STDIN(if environment variable REQUEST_METHOD == POST) or from environment variable QUREY_STRING(if GET).
b. resolve data into independent results such as "supermyself mxb red basketball "
c. writing results to STDOUT

marghorp 06-12-2005 03:10 PM

Sorry my missinterpretation. I programmed CGI with Perl and just assumed you mean that too :P

Silly me.

Well, you will probably need to setup your server to know how to interpret your scripts.

As I recall it from Perl, you needed the first line to tell the server what language it is in:

in Perls case this was #!/usr/bin/perl

In your case it could be something like:

#!/bin/bash or #!/bin/sh
Anyway, you could then try to access this script from the webserver, like this:

http://localhost/script.cgi (presuming you named your script script.cgi and placed it in your webroot directory)


All times are GMT -5. The time now is 01:18 PM.