running shell scripts with CGI on a web browser

Anyone here have experience running a production setup through a browser? I have a Linux shell script that I want to run as a CGI script. I have no idea how any of this software stuff works, the web, shells, etc. I guess I have an overall grasp of how systems work, but all the web/ linux documentation is either way too sparse, or assumes a deep working knowledge of CGI, lighttpd, HTML. For example, even after reading the documentation, the documentation never mentionned that the /cgi-bin directory needs to be in the documentroot folder defined in a configuration file, and not necessarily the /usr/lib/cgi-lib directory the documentation keeps talking about. It's also not clear how to pass the setting of a HTML "form" to the script... They keep talking about environment variables... But it seems to depend on how your HTML is set up... I finally got some data to pass to the script by changing the form from a POST to a GET... And even then, the production script itself doesn't behave the same when run as a CGI script... It's all very annoying.

Reply to
a7yvm109gf5d1
Loading thread data ...

You're in the wrong newsgroup, try up in the linux groups and the web authoring groups maybe, I've not been there for ages. CGIs are largely automated and hidden by non-secure modern programming languages these days, it seems.

A simple example of cgi scripting is here:

formatting link

It'll show you the environment variable names and content as set by your access to that web page.

Grant.

Reply to
Grant

First, the web server needs to have CGI enabled, and you need to define a "cgi-bin" directory (via the ScriptAlias directive for Apache). This directory is normally outside of the DocumentRoot directory, so that normal users can't upload CGI scripts. Then, you put the script into the cgi-bin directory and give it execute permission.

If the script is invoked in response to a GET or PUT method, the form data (following the "?" at the end of the URL) will be available via the QUERY_STRING environment variable. If it's invoked in response to a POST method, the data will be available via the script's stdin. In either case, the data will be URL-encoded: characters which are significant in URLs will be encoded in hex as %xx, spaces will either be changed to plus signs or encoded as hex (%20).

Form input should normally use POST, particularly if the amount of data is non-trivial or if any of it might be confidential. If you use GET or PUT, the form data will be part of the URL, so it will appear in the address bar, browser history, the Referer: header of any request initiated from the page generated by the CGI script, etc.

The script should normally generate a header consisting of a Content-Type line, followed by a blank line, followed by the data (e.g. HTML).

Reply to
Nobody

I've done this before. Email me at richgrise at yahoo dot com. But if it's for a revenue-producing project, it's only fair to warn you that I don't work for free. ;-)

Cheers! Rich

Reply to
Rich Grise

On a sunny day (Thu, 24 Mar 2011 20:30:22 -0700 (PDT)) it happened snipped-for-privacy@netzero.com wrote in :

Just to add to the multitude of choices, have you looked at php? Could be easier for you and there are plenty examples on the web.

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.