Sponsored Content
Special Forums UNIX and Linux Applications execute shell script using CGI for html site Post 302513889 by DGPickett on Thursday 14th of April 2011 09:32:30 AM
Old 04-14-2011
The base shell and web service are not too compatible, both because shell needs help decoding URLencoded strings and because it is easy to open security holes (shell injection, I guess you could call it) with metacharacters in input. You can do some simple things, especially when the user input is not required, like a report with no inputs and no forms, just information or links.

The rules of CGI are pretty simple, and executables in you cgi-bin subtree will get called by the web server. Scripts may not act like they do interactively, since there is no tty. Basicly, you write to stdout a good http header minus the first line, blank line and whatever document you want, then exit 0. Get input is by env var., and post by read-it-yourself from stdin. There are a handful of support variables. You can see them with this cgi script:
Code:
#!/usr/bin/ksh
 
echo "Content-type:text/plain
 
CGI Environment:
'
 
set 
 
echo '
---- END ----'


Last edited by DGPickett; 04-14-2011 at 10:42 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

HTML-CGI on Unix

AAAHHH!! I've made a perl program that you can run on a web browser. This program needs to be run everyday, and I don't want to have to run it everyday. The problem is when I try running the program from my terminal, all it does is print stuff to the terminal page (the program involves a lot of... (4 Replies)
Discussion started by: sstevens
4 Replies

2. Shell Programming and Scripting

HTML form to cgi help

I wrote a script to automate user account verification against peoplesoft. Now I want to make it available to my peers via the web. It is running on Solaris. I have the form written, but am not sure how to make it work. I think the form should call a perl cgi when submitted. The cgi should call... (7 Replies)
Discussion started by: 98_1LE
7 Replies

3. Shell Programming and Scripting

html - df -k cgi script

Hey - I am new to cgi scripting... just writing a script to output df -k output to html page... but I cannot get the df lines on separate lines on the page, it all comes out on one line and is not very readable.. any suggestions? My script is below - please keep in mind I am only new to it so... (1 Reply)
Discussion started by: frustrated1
1 Replies

4. Shell Programming and Scripting

cgi script to echo a html file

Hi, I'm learning some simple cgi scripting. I can make a script like this, so my browser shows "Hello World" /www/cgi-bin/name.sh --- #!/bin/sh MyName=World echo "<html> Hello $MyName </html>" --- What I'd like is to have a separate html and script files in the cgi folder so ... (1 Reply)
Discussion started by: Performer
1 Replies

5. Shell Programming and Scripting

invoking a shell script inside cgi shell script

Hi, I have an HTML form through which I get some text as input. i need to run a shell script say script.sh inside a perl-cgi script named main_cgi.sh on the form input. I want to write the contents of the form in a file and then perform some command line operations like grep, cat on the text... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

6. Shell Programming and Scripting

How can I execute a shell script from an html link?

I want to execute a shell script when clicking on an html link. I want the output of the script to be shown on the webpage. Whats the best way to achieve this? (6 Replies)
Discussion started by: streetfighter2
6 Replies

7. Shell Programming and Scripting

How to pass data from server (CGI script) to client (html page)

Hi I know how to pass data from client side (html file) to server using CGI script (POST method). I also know how to re-create the html page from server side after receiving the data (using printf). However I want to write static pages on client side (only the structure), and only to pass... (0 Replies)
Discussion started by: naamabm
0 Replies

8. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

9. UNIX for Dummies Questions & Answers

Trying to execute a script to populate all directories with index.html

Hello, I am trying to create a php file that would copy given index.html file to all directories (and subdirectories) on my site that don't have one. This is to prevent directory listings on nginx. This index.html file is placed in the /populate directory and looks like this: <html> <head>... (7 Replies)
Discussion started by: teletubby
7 Replies

10. UNIX for Beginners Questions & Answers

How to convert my /bin/sh script with cgi and html to run it on browser!??

Hello, I want to run this script on my CentOS 6 via browser : ________________________________________________________________________________________________ #!/bin/sh echo Username? read MY_NAME echo Provisional file name? read MY_FILE echo File NAME you want to save? read MY_FILE2... (16 Replies)
Discussion started by: juta2020
16 Replies
CGI(3pm)						User Contributed Perl Documentation						  CGI(3pm)

NAME
APR::Request::CGI - wrapper for libapreq2's CGI handle. SYNOPSIS
use APR::Request::CGI; my $req = APR::Request::CGI->handle($pool); DESCRIPTION
The APR::Request::CGI module provides a constructor for accessing CGI request data associated to a pool via libapreq2. This manpage documents version 2.13 of the APR::Request::CGI package. METHODS
APR::Request::CGI - derived from "APR::Request". handle APR::Request::CGI->handle($pool) Creates an APR::Request::CGI object. The argument $pool is an APR::Pool object. SEE ALSO
APR::Request, APR::Pool. COPYRIGHT
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. perl v5.10.1 2011-02-28 CGI(3pm)
All times are GMT -4. The time now is 01:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy