Sponsored Content
Top Forums Shell Programming and Scripting cgi script to echo a html file Post 302180782 by Performer on Tuesday 1st of April 2008 06:16:24 AM
Old 04-01-2008
I should add that my cgi shell is ash (Busybox)
 

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

CGI passing arrays/hashes to another CGI script

If I have a Perl CGI script (script01), which fills an array(s) with information and outputs a HTML page with a link to another CGI page (script02); is there anyway to pass the array(s) from "script01" to "script02" when the page visitor clicks the link? Hope that makes sense! :) (2 Replies)
Discussion started by: WIntellect
2 Replies

3. 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

4. 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

5. 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

6. UNIX and Linux Applications

execute shell script using CGI for html site

hi there im currently in the process of creating a website for use basically within our org. im using a os x machine and installed MAMP - which includes Apache, mysql... the site will be used by techs to primarily install pkgs files onto os x devices. i would like to have buttons or hyperlinks... (2 Replies)
Discussion started by: sheshe
2 Replies

7. Shell Programming and Scripting

Writing html to a file with echo

Hi, I'm having an issue with echo again. I keep getting errors and no file content with these commands in a script. --------------------------------------------------- #!/bin/bash WEBSITE=http://www.google.com touch test1.txt echo "replace("<body>","<body><iframe... (2 Replies)
Discussion started by: digitalviking
2 Replies

8. Shell Programming and Scripting

Can't create file in CGI Script

Hi I have some simple script within the context of a cgi script that create a file to write to. If I run the script from the command line as root the file is created with no issue. However when I run the script from a web page with the apache account, it dies. The code lines are: sub... (3 Replies)
Discussion started by: larryjmoon
3 Replies

9. Shell Programming and Scripting

Run command through html+cgi in bash

Hi everyone, I want to kill process through the web, so I create html page with single bottom that run kill command in shell script with CGI. Here is html code: <td><form METHOD="GET" action="http://IP:port/cgi_bin/script.cgi" > <input type="submit" value= "Submit" > <INPUT name="q"... (7 Replies)
Discussion started by: indeed_1
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
SSI(3pm)						User Contributed Perl Documentation						  SSI(3pm)

NAME
CGI::SSI - Use SSI from CGI scripts SYNOPSIS
# autotie STDOUT or any other open filehandle use CGI::SSI (autotie => 'STDOUT'); print $shtml; # browser sees resulting HTML # or tie it yourself to any open filehandle use CGI::SSI; open(FILE,'+>'.$html_file) or die $!; $ssi = tie(*FILE, 'CGI::SSI', filehandle => 'FILE'); print FILE $shtml; # HTML arrives in the file # or use the object-oriented interface use CGI::SSI; $ssi = CGI::SSI->new(); $ssi->if('"$varname" =~ /^foo/'); $html .= $ssi->process($shtml); $ssi->else(); $html .= $ssi->include(file => $filename); $ssi->endif(); print $ssi->exec(cgi => $url); print $ssi->flastmod(file => $filename); # # or roll your own favorite flavor of SSI # package CGI::SSI::MySSI; use CGI::SSI; @CGI::SSI::MySSI::ISA = qw(CGI::SSI); sub include { my($self,$type,$file_or_url) = @_; # my idea of include goes something like this... return $html; } 1; __END__ # # or use .htaccess to include all files in a dir # # in .htaccess Action cgi-ssi /cgi-bin/ssi/process.cgi <FilesMatch ".shtml"> SetHandler cgi-ssi </FilesMatch> # in /cgi-bin/ssi/process.cgi #!/usr/local/bin/perl use CGI::SSI; CGI::SSI->handler(); __END__ DESCRIPTION
CGI::SSI is meant to be used as an easy way to filter shtml through CGI scripts in a loose imitation of Apache's mod_include. If you're using Apache, you may want to use either mod_include or the Apache::SSI module instead of CGI::SSI. Limitations in a CGI script's knowledge of how the server behaves make some SSI directives impossible to imitate from a CGI script. Most of the time, you'll simply want to filter shtml through STDOUT or some other open filehandle. "autotie" is available for STDOUT, but in general, you'll want to tie other filehandles yourself: $ssi = tie(*FH, 'CGI::SSI', filehandle => 'FH'); print FH $shtml; Note that you'll need to pass the name of the filehandle to "tie()" as a named parameter. Other named parameters are possible, as detailed below. These parameters are the same as those passed to the "new()" method. However, "new()" will not tie a filehandle for you. CGI::SSI has it's own flavor of SSI. Test expressions are Perlish. You may create and use multiple CGI::SSI objects; they will not step on each others' variables. Object-Oriented methods use the same general format so as to imitate SSI directives: <!--#include virtual="/foo/bar.footer" --> would be $ssi->include(virtual => '/foo/bar.footer'); likewise, <!--#exec cgi="/cgi-bin/foo.cgi" --> would be $ssi->exec(cgi => '/cgi-bin/foo.cgi'); Usually, if there's no chance for ambiguity, the first argument may be left out: <!--#echo var="var_name" --> could be either $ssi->echo(var => 'var_name'); or $ssi->echo('var_name'); Likewise, $ssi->set(var => $varname, value => $value) is the same as $ssi->set($varname => $value) $ssi->new([%args]) Creates a new CGI::SSI object. The following are valid (optional) arguments: DOCUMENT_URI => $doc_uri, DOCUMENT_NAME => $doc_name, DOCUMENT_ROOT => $doc_root, errmsg => $oops, sizefmt => ('bytes' || 'abbrev'), timefmt => $time_fmt, MAX_RECURSIONS => $default_100, # when to stop infinite loops w/ error msg COOKIE_JAR => HTTP::Cookies->new, $ssi->config($type, $arg) $type is either 'sizefmt', 'timefmt', or 'errmsg'. $arg is similar to those of the SSI "spec", referenced below. $ssi->set($varname => $value) Sets variables internal to the CGI::SSI object. (Not to be confused with the normal variables your script uses!) These variables may be used in test expressions, and retreived using $ssi->echo($varname). These variables also will not be available in external, included resources. $ssi->echo($varname) Returns the value of the variable named $varname. Such variables may be set manually using the "set()" method. There are also several built-in variables: DOCUMENT_URI - the URI of this document DOCUMENT_NAME - the name of the current document DATE_GMT - the same as 'gmtime' DATE_LOCAL - the same as 'localtime' LAST_MODIFIED - the last time this script was modified $ssi->exec($type, $arg) $type is either 'cmd' or 'cgi'. $arg is similar to the SSI "spec" (see below). $ssi->include($type, $arg) Similar to "exec", but "virtual" and "file" are the two valid types. SSI variables will not be available outside of your CGI::SSI object, regardless of whether the virtual resource is on the local system or a remote system. $ssi->flastmod($type, $filename) Similar to "include". $ssi->fsize($type, $filename) Same as "flastmod". $ssi->printenv Returns the environment similar to Apache's mod_include. $ssi->cookie_jar([$jar]) Returns the currently-used HTTP::Cookies object. You may optionally pass in a new HTTP::Cookies object. The jar is used for web requests in exec cgi and include virtual directives. FLOW-CONTROL METHODS The following methods may be used to test expressions. During a "block" where the test $expr is false, nothing will be returned (or printed, if tied). $ssi->if($expr) The expr can be anything Perl, but care should be taken. This causes problems: $ssi->set(varname => "foo"); <!--#if expr="'$varname' =~ /^foo$/" -->ok<!--#endif --> The $varname is expanded as you would expect. (We escape it so as to use the $varname within the CGI::SSI object, instead of that within our progam.) But the $/ inside the regex is also expanded. This is fixed by escaping the "$": <!--#if expr="'$varname' =~ /^value$/" -->ok<!--#endif --> The expressions used in if and elif tags/calls are tricky due to the number of escapes required. In some cases, you'll need to write "\\" to mean "". $ssi->elif($expr) $ssi->else $ssi->endif SEE ALSO
"Apache::SSI" and the SSI "spec" at http://www.apache.org/docs/mod/mod_include.html AUTHOR
(c) 2000-2005 James Tolley <james@bitperfect.com> All Rights Reserved. This is free software. You may copy and/or modify it under the same terms as perl itself. CREDITS
Many Thanks to Corey Wilson and Fitz Elliot for bug reports and fixes. perl v5.12.4 2007-08-08 SSI(3pm)
All times are GMT -4. The time now is 08:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy