Sponsored Content
Top Forums Shell Programming and Scripting how to generate html file using script? Post 302199094 by kpearson on Sunday 25th of May 2008 11:38:21 PM
Old 05-26-2008
Agreed. I use bash scripts for my cgi and output plenty of data, building HTML on the fly.

For example, I have a help topics page for my wife that is entirely scripts. I add a small text file, and the script formats it and puts it on the webpage in alphabetical order.

I.e:

Clothing_And_Shoes

would be the name of the text file, and inside would be some simple information.

Here's a copy of a script named ShowHelp.cgi that would be called from index.shtml (SSI must be enabled) and would output the text files:

Code:
#!/bin/sh
cnt=0
printf 'content-type: text/html\n\n'
LST=`ls|grep -v cgi|grep -v html`
for i in $LST
 do
  cnt=$(($cnt+1))
  LNK=$i
  NM=`echo $i|tr '_' ' '`
  printf "<tr><td align=justify bgcolor=white><center><a name=$LNK>Note $cnt:<b>&nbsp;&nbsp;$NM</b></center><br>"
  printf '<table border=0 align=center cellpadding=0 cellspacing=0 bgcolor=white><tr><td align=justify>'
  cat $i
  printf "<p align=center><a href=#TOP>Top of Page</a></p>"
  printf "</td></tr></table>"
  printf "</td></tr>"
done

Hopefully that will help, but as scarfake said, without some information of what precisely you need, we're just guessing.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate report in HTML file from Oracle DB

Hi Team, I need a suggestion/comments for my below requirement. I have a procedure which performs some DDL operations & loads data into a Oracle table. This status contains Audit data. What i wanted to do is, once the procedure is completed (daily), shell script should retrive the data from the... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

2. Shell Programming and Scripting

KSH - help needed for creating a script to generate xml file from text file

Dear Members, I have a table in Oracle DB and one of its column name is INFO which has data in text format which we need to fetch in a script and create an xml file of a new table from the input. The contents of a single cell of INFO column is like: Area:app - aam Clean Up Criteria:... (0 Replies)
Discussion started by: Yoodit
0 Replies

3. Shell Programming and Scripting

Script to generate csv file

Hello; I need to generate a csv file that contains a list of all the files in a particular server (from the root directory ie: \) that have a permission stamp of 777. I would like to create the csv so that it contains the following: server name, file name, full path name where file exists,... (17 Replies)
Discussion started by: gvolpini
17 Replies

4. UNIX for Dummies Questions & Answers

How to generate html reports through LINUX Scripting?

Hi All, I am trying to generate a weekly HTML report using LINUX Scripting. This will have record counts of some files. (like below) touch path/filename.html echo "Weekly Summary Report for Business Date : $P_BUS_DT">path/filename.html export A1=`cat path/filename1.txt |wc -l` echo "A1... (6 Replies)
Discussion started by: dsfreddie
6 Replies

5. Shell Programming and Scripting

Script To Generate HTML output

Hello All, I need help here with a script. I have a script here which generates a html output with set of commands and is working fine. Now i want to add a new command/function which would run on all the remote blades and output should be included in this html file. Here is the script ... (2 Replies)
Discussion started by: Siddheshk
2 Replies

6. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

7. Shell Programming and Scripting

How to generate HTML page from UNIX script out-put?

Hi All. This my first post to this forum, and i assuming it will be best out-of all. I am quite new to Unix scripting so please excuse me for any silly questions - I am trying to create on Unix script in which it telnet to my server, check the connectivity of the server and then it... (2 Replies)
Discussion started by: HHarsh
2 Replies

8. UNIX for Dummies Questions & Answers

Need script to generate file.

Hi I have a file "test" with data as below 1,APRIL,NEW,"New market,delhi,pune,India",RECENT, 254664 2,MARCH,OLD,"New Area,Mumbai,UP,India",CURRENT, 152483 So I want a script which provides output as below 1,APRIL,RECENT,254664 2,MARCH,CURRENT,152483 I am aware we can use awk/sed... (9 Replies)
Discussion started by: sv0081493
9 Replies

9. Shell Programming and Scripting

Script to generate HTML output format listing like orasnap

Hi, Is there any UNIX scripts out there that generates a listing output of some sort similar to OraSnap At the moment, I have a script that I run on multiple servers that has multiple databases and just querying the database sizes of those databases. It generates a text files that contains... (0 Replies)
Discussion started by: newbie_01
0 Replies

10. Shell Programming and Scripting

Script to generate csv file

Dears, I am new in shell world and I need your help in this, I have to create a report based on the output file generated by another program. I want to write a shell script for this. The output file generated every 15 minutes but i can’t open it until the end of day so the script will get the... (3 Replies)
Discussion started by: abdul2020
3 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 01:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy