[Techtalk] Perl script how to

Tamara Harpster tamara.harpster at gmail.com
Mon Aug 28 20:34:06 UTC 2006


Let me see if I can explain a little more on this. You can have the script
run at the command line and still not have it activated by the form when the
HTML page calls it. And the library I am referring to is a CGI library that
allows reading the variables from the web server, for example, the value of
the select option that is sent.

In order to run the script, you need the following:
1. In the HTML form, at the top of the form, you need the following tag,
with this minimal information:

<form action="scriptname" method="get">
where the scriptname is the name and location of your script on
the webserver, for example, for a perl script it might be

<form action="/cgi-bin/getform.pl" method="get">

where the script getform.pl is located in the cgi-bin directory
on the webserver

2. The webserver has to be configured to allow running your script.
 For Perl in Apache, this is built-in by using an exentsion of .cgi
for PHP you have to insall a module for Apache to load. With IIS,
when Perl is installed, make sure it installs the option for web
server support. And the mime type must be set for the Apache to indicate
what kind of files are to be executed.

3. On Linux/Unix boxes the permissions must be set to allow execution
for webserver.

4. The called script or program must have some way of reading the
information the web server sends to it, if you want it to respond
to input fields set in the form.

5. For most scripts, they must specify how they are returning the
data, otherwise the web server doesn't know what to do with it.
For Perl, this is done by printing out a top line of "Context: text/mime"
which tells the web server that the following print statements should
be treated as text. If you were printing out a graphic, you would
use a different mime type.

Once those items are setup, your HTML form can call and activate the
script. You can test this out by creating a simple script that
prints out a test message just to see if that works, then work on
getting the HTML form field processing.

Hope this provides a bit more clarification.

tamara



On 8/28/06, Helen <hrosseau at rogers.com> wrote:
>
>  Thanks for the responses
>
> I guess I am not clear on this.
> I need an html page that will perform the function in the expect script
> and then return back to the html page the results from the expect script.
> Yes I have all the libraries as I can run the scripts manually.  My problem
> is that when I cause the form to get(the expect script), I can't seem to get
> it to actually run the expect script. There was reference to either using
> java or perl.  From my reading, I still can't construct an html page that
> will process or call the script selected.  I've looked at php briefly, I am
> not sure if it will do what I need to do.
>
> I am still looking and trying.
>
> Helen
>
> ----- Original Message -----
> *From:* Tamara Harpster <tamara.harpster at gmail.com>
> *To:* Helen <hrosseau at rogers.com>
> *Cc:* techtalk at linuxchix.org
> *Sent:* Monday, August 28, 2006 3:35 PM
> *Subject:* Re: [Techtalk] Perl script how to
>
> Based on your description, it sounds like this is what you are trying to
> do one of the following:
>
> 1. Have an HTML form with select options. When the user has selected an
> option and submitted the form, the HTML page will be redisplayed with the
> addition of a text box that has the selected option text in it
> 2. Have an HTML form with select options. When the user selects an option
> on that page, another input field on that page, a text box, is updated with
> the information from the selected option.
>
> For option 1 you would use CGI to process the information, for option 2
> you would use Javascript and the DOM to process the event and update the
> box. Based on your e-mail, I'm including information about option 1. My
> apologies if some of this information seems rudimentary, I'm not sure what
> background you already have, and based on your comments I may be providing
> more information than you need.
>
> In order to use CGI, you need to be able to process information that the
> web server is passing to you. CGI stands for Common Gateway Interface and
> only defines what type of information the Web Server will send for a backend
> program to process. The reason Perl was recommended is that there is an
> existing library for Perl that allows you to get the values from the HTML
> form and to process them. The scripting language PHP also has this
> capability built in through the use of PHP variables or functions that you
> can use.
>
> It sounds like your expect scripts don't have this library for retrieving
> the data or are not making use of it. And there are two different formats
> for the received data based on the method used in the HTML form. The two
> methods are GET and POST. When using the GET , the variables are passed in
> with the URL, when using POST, the variables are passed in with the HTTP
> request alone and are not duplicated on the URL line. For web applications
> that need to pass in large amounts of data or uploading files, POST is the
> recommended method, otherwise for debugging purposes, GET works fine.
>
> One resource for Perl scripts is at www.cgi-resources.com, they have quite
> a few scripts available, along with some other languages. Or if you want to
> use expect scripts, I would recommend looking for a library or set of
> routines that would work with a web server to get the CGI information and
> pass it to your script.
>
> I hope this was helpful.
>
> tamara
>
> On 8/28/06, Helen <hrosseau at rogers.com > wrote:
> >
> > I have been researching and reading until I feel like I have banged my
> > head
> > against a wall enough.  I am looking for help.  I have approached all of
> > the
> > programmers in my area and I think I am in a different world.  None use
> > perl. They all program in C.  And I am not a programmer.
> >
> > What I am trying to do is have an html page call up my expect scripts
> > via
> > something like the select option and output the text to a text area on
> > the
> > same html page that called it. One article said to use perl and that
> > would
> > solve all my problems.  The problem is I don't know perl.  I can use cgi
> > scripts (if I could write them well) but I don't seem to get it
> > right.  I
> > have tried to understand how to call the scripts, but I am getting
> > nowhere
> > fast.  Frustration has hit a new high.
> >
> > Does anyone know of either a good script that I can understand to make
> > the
> > modifications to, or reccommend another method.  I can run the expect
> > scripts and the perl scripts manually, but I can't seem to be able to
> > call
> > them from an html page or how to output the results to the same page.
> >
> > Helen
> >
> > _______________________________________________
> > Techtalk mailing list
> > Techtalk at linuxchix.org
> > http://linuxchix.org/mailman/listinfo/techtalk
> >
>
>
>
> --
> "Do not anger the dragon, for you are crunchy and taste good with ketchup"
>
>
>


-- 
"Do not anger the dragon, for you are crunchy and taste good with ketchup"


More information about the Techtalk mailing list