Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using parameter of shell script in CGI

Status
Not open for further replies.
Aug 22, 2002
113
FR
Hello,


I've wrote a shell script that uses a parameter to run with different options. How do I pass this parameter to the shell script in CGI?

From the Unix shell, the script is invoked like this:

./status.sh PARAM

The script will then read the $1 environment variable and process accordingly.

How can this be done in CGI/SSI?

My SSI looks like this:

<!--#exec cgi=&quot;/cgi-bin/status.sh&quot; -->


Thanks for your help.
 
<!--#exec cgi=&quot;/cgi-bin/status.sh?param_name1=value1&quot; -->

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Thanks for your help but what would I put in param_name1 and value1? In the script I call a parameter, not a parameter and a value.

Thanks for all your help.
 
If you are going to use the HTML include 'exec cgi' trick to call your shell script, then you must make the shell script behave like a comformant piece of CGI code. The 'exec' in your HTML is parsed and processed by the web server which will assume that since you are 'exec'ing a 'CGI', you will build an appropriate URL in a manner that is meaningful to a CGI application.

When you pass values to a CGI application you do it with a name for the parameter and a value for the parameter. Given the following HTML:
Code:
<html><body><form action='TARGET_CGI'>
<input type='textbox' name='phone' value='890-1234' />
<input type='submit' />
</form></body></html>

The parameter name is 'phone' and the parameter value is '890-1234'. You get the same result by putting the name=value pair in a URL.

Code:
<a href='[URL unfurl="true"]http://www.yourserver.com/cgi-bin/your.cgi?phone=890-1234'>submit[/URL] phone to CGI app</a>

Your shell script will need to be able to parse the URL string to capture the phone number (or whatever paramter you're passing). If this is difficult in the shell script, why not write a little Perl to do what the shell script is doing?

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top