| View previous topic :: View next topic |
| Author |
Message |
krixham
Joined: 11 Jan 2005
Posts: 5
|
| Posted: Tue Jan 11, 2005 1:18 pm Run a script inside an HTML page |
|
|
I admit to being totally new. I am making progress, but I'm stuck on one issue.
I have an HTML page that a user will click on one of three choices. What I want to do is display items in a PERL script on a second page, similar to the first. I was hoping to be able to launch a PERL script.
So far, everything I have done is causing the PERL script to launch a second window, and it's very basic text.
I'm sure that there is an easy way to do this. I've looked at <script> and <form>. It's not doing anything. I need the results of the script posted to the html page.
Does any of this make any sense?
Thanks!
Kathy :oops: |
|
|
kanenas
Joined: 14 Dec 2004
Posts: 341
|
| Posted: Thu Jan 13, 2005 2:16 am Re: Run a script inside an HTML page |
|
|
krixham wrote: I have an HTML page that a user will click on one of three choices. What I want to do is display items in a PERL script on a second page, similar to the first. I was hoping to be able to launch a PERL script.
Do you mean, using CGI, have a Perl script to generate a webpage?
krixham wrote:
So far, everything I have done is causing the PERL script to launch a second window, and it's very basic text.
I'm sure that there is an easy way to do this. I've looked at <script> and <form>. It's not doing anything. I need the results of the script posted to the html page.
Does any of this make any sense?
Almost.
In the text of the question, the distinction between server- and client-side scripting are getting muddled. While <script> is what denotes a client-side script in a web page, HTML tags will have nothing to do with running a server-side script. What I'm assuming you are actually doing is running a server side Perl script using, I'm also assuming, CGI. To generate HTML using Perl, make sure you print a "Content-Type: text/html" header (before you print the body, of course). You can do this with any of:
print "Content-Type: text/html\n\n";
use CGI ':standard';
print header(-type => 'text/html')
use CGI ':standard';
print header();
For the document itself, just have the Perl script print HTML tags where appropriate (see examples below). You can also create the HTML start and end tags and document head using the CGI subs start_html and end_html.
Examples:
Code:
#! /usr/bin/perl
print "Content-Type: text/html\n\n";
print <<EOF ;
<HTML>
<HEAD>
<TITLE>Test Page</TITLE>
</HEAD>
<BODY>
<H2>Test page.</H2>
</BODY>
</HTML>
EOF
Code:
#! /usr/bin/perl
use CGI ':standard';
print header,
start_html('Test page'),
h2('Test page'),
end_html;
If you want to know more, use Google to find Perl CGI scripting tutorials/articles. For details on the Perl CGI package, see the CGI module documentation. This document is a bit much to start on, so it's best used as a reference until the day you can consume documentation like Jell-O. |
|
|
krixham
Joined: 11 Jan 2005
Posts: 5
|
| Posted: Thu Jan 13, 2005 5:26 am Re: Run a script inside an HTML page |
|
|
Thanks so much for the suggestions. What I have now is a very basic command line series of menus to list and print jobs in a production printing environment. The programs to run these menus are what I call scripts. Some are written in PERL and some are written in KORN.
Since my posting, I have discovered the world of frames. That technique has worked. I didn't know how to 'pretty up' the text, but thanks to this posting I now have an idea.
Next step is to add hyper links from the choice to the 'script' that needs to run in the background to route the document to the printer.
Hey, I'm a System Analyst. I thought I got out of programming a LONG time ago! :P
Thanks, again! Any other suggestions would be most welcome!
Kathy |
|
|
| |
|
|
|