LinuxQuestions.org
Review your favorite Linux distribution.
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 06-12-2005, 05:55 AM   #1
supermyself
LQ Newbie
 
Registered: May 2005
Posts: 17

Rep: Reputation: 0
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>
 
Old 06-12-2005, 09:10 AM   #2
marghorp
Senior Member
 
Registered: Jan 2004
Location: Slovenia
Distribution: Slackware 10.1, SLAX to the MAX :)
Posts: 1,040

Rep: Reputation: 45
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.
 
Old 06-12-2005, 10:10 AM   #3
supermyself
LQ Newbie
 
Registered: May 2005
Posts: 17

Original Poster
Rep: Reputation: 0
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
 
Old 06-12-2005, 04:10 PM   #4
marghorp
Senior Member
 
Registered: Jan 2004
Location: Slovenia
Distribution: Slackware 10.1, SLAX to the MAX :)
Posts: 1,040

Rep: Reputation: 45
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)
 
  


Reply


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
Directory listing - Calling shell script from a CGI script seran Programming 6 08-12-2005 12:08 AM
Python CGI script can't write files, permission denied The_Nerd Programming 4 03-17-2005 01:19 PM
how to execute shell scripts from cgi script rajatgarg Linux - General 1 07-08-2004 02:39 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM
Running a shell script via CGI-BIN chrisk5527 Linux - General 3 05-09-2003 12:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:56 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration