You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "David M. Spreitzer" <ds...@hscil.com> on 2001/08/14 20:52:41 UTC

HTML::EmbperlObject::Execute w/in CGI

I'm a Embperl newbie needing some help.

I've implementing EmbperlObject for generating the html pages, which btw
worked great.  Now I'd like to use the component files (headers/footers)
within  some existing cgi scripts. I think HTML::EmbperlObject::Execute
is my answer, but I'm having some trouble implementing this
functionality.

1) is this possible and is EmbperlObject::Execute really what I'm
looking for?

2) given the following, am I missing/over-looking anything, or just
doing it wrong.

3) the log file shows it finds and does some processing on the
components, but not output is generated on the browser.

4) Can the log output be piped to a another program, like Apache
CustomLog pipe directive.

using Apache/1.3.17 (solaris)
      mod_perl/1.25
      Embperl 1.3.1

http config file entry:
(Some EMBPERL entries are probably not need, but I included them anyway)
        <Files *.epl>
            PerlSetEnv EMBPERL_OBJECT_BASE base.ep
            PerlSetEnv EMBPERL_FILESMATCH "\.epl"
            PerlSetEnv EMBPERL_DECLINE "\.ep"
            PerlSetEnv EMBPERL_OBJECT_ADDPATH /web/apache/embperl
            PerlSetEnv EMBPERL_OBJECT_FALLBACK missing_handler.embperl

            PerlSetEnv EMBPERL_DEBUG 30

             PerlSendHeader On
             SetHandler perl-script
             PerlHandler Apache::Registry
             Options +ExecCGI
        </Files>

cgi script:
#!/usr/local/bin/perl

use strict;
require CGI;
CGI->import(qw(:standard :html3 font));

use HTML::EmbperlObject;
              
main();

sub main {
    print header(),start_html();

#    my $Logfile = '|/usr/local/sbin/cronolog
/usr/local/apache/logs/%Y/%m/%d/embperl_log';
    my $Logfile = '/tmp/embperl_log_test';
    my $DebugDefault = 2285;
    HTML::Embperl::Init ($Logfile, $DebugDefault);
    HTML::Embperl::ScanEnvironment;

    HTML::EmbperlObject::Execute ({inputfile => 'table.ep'});
    HTML::EmbperlObject::Execute ({inputfile => 'title.ep'});

    print end_html();
}


file table.ep:
[- @link = (
"1",
"2"
) -]

[- @name = (
"1",
"2"
) -]

start table
[- $i = 0 -]
<table border=0 cellpadding=3 cellspacing=0 width=100%>
[$ do $]
    <tr><td>
        <table border=0 cellpadding=1 cellspacing=0 width=100%
bgcolor=#6699cc> <tr><td>
            <table border=0 cellpadding=5 cellspacing=0 width=100%
bgcolor=#e7effa> <tr><td>
                <a href=[+ $link[ $i ] +]><b>[+ $name[ $i ] +]</b></a>
            </td></tr> </table>
        </td></tr> </table>
    </td></tr>
[- $i++ -]
[$ until $i > $#link $]
</table>
end table


file title.ep:
<h2>
       [- @time = split /[\s:]/, localtime; -]
       [$ if ( $time[3] < 12 ) $]
       Good morning
       [$ elsif ( $time[3] < 17 ) $]
       Good afternoon
       [$ else $]
       Good evening
       [$ endif $]
</h2>

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: HTML::EmbperlObject::Execute w/in CGI

Posted by Gerald Richter <ri...@ecos.de>.
>
> 1) is this possible and is EmbperlObject::Execute really what I'm
> looking for?
>

When I understand right what you want to do, Embperl::Execute would be
better. (It just includes your header/footer at the desired place)

If you have a CGI that doesn't generate any output (only does computation)
and you want to have the whole feature of EmbperlObject, then
EmbperlObject::Execute is the right one to use. (but in this case you also
have to use EmbperlObject::ScanEnvironment)

> 2) given the following, am I missing/over-looking anything, or just
> doing it wrong.
>

If you mix output from Embperl and your CGI you have to set the Option
optRedirectStdout, either by passing it to Execute, or by setting it in your
httpd.conf

>
> 4) Can the log output be piped to a another program, like Apache
> CustomLog pipe directive.
>

embperl.log cannot piped to another program

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: HTML::EmbperlObject::Execute w/in CGI

Posted by Dimitri Ostapenko <d...@perlnow.com>.
"David M. Spreitzer" wrote:
> 
> I'm a Embperl newbie needing some help.
> 
> I've implementing EmbperlObject for generating the html pages, which btw
> worked great.  Now I'd like to use the component files (headers/footers)
> within  some existing cgi scripts. I think HTML::EmbperlObject::Execute
> is my answer, but I'm having some trouble implementing this
> functionality.
> 
> 1) is this possible and is EmbperlObject::Execute really what I'm
> looking for?
> 
> 2) given the following, am I missing/over-looking anything, or just
> doing it wrong.
> 
> 3) the log file shows it finds and does some processing on the
> components, but not output is generated on the browser.
> 
> 4) Can the log output be piped to a another program, like Apache
> CustomLog pipe directive.
> 
> using Apache/1.3.17 (solaris)
>       mod_perl/1.25
>       Embperl 1.3.1
> 
> http config file entry:
> (Some EMBPERL entries are probably not need, but I included them anyway)
>         <Files *.epl>
>             PerlSetEnv EMBPERL_OBJECT_BASE base.ep
>             PerlSetEnv EMBPERL_FILESMATCH "\.epl"
>             PerlSetEnv EMBPERL_DECLINE "\.ep"
>             PerlSetEnv EMBPERL_OBJECT_ADDPATH /web/apache/embperl
>             PerlSetEnv EMBPERL_OBJECT_FALLBACK missing_handler.embperl
> 
>             PerlSetEnv EMBPERL_DEBUG 30
> 
>              PerlSendHeader On
>              SetHandler perl-script
>              PerlHandler Apache::Registry
>              Options +ExecCGI
>         </Files>
> 
> cgi script:
> #!/usr/local/bin/perl
> 
> use strict;
> require CGI;
> CGI->import(qw(:standard :html3 font));
> 
> use HTML::EmbperlObject;
> 
> main();
> 
> sub main {
>     print header(),start_html();
> 
> #    my $Logfile = '|/usr/local/sbin/cronolog
> /usr/local/apache/logs/%Y/%m/%d/embperl_log';
>     my $Logfile = '/tmp/embperl_log_test';
>     my $DebugDefault = 2285;
>     HTML::Embperl::Init ($Logfile, $DebugDefault);
>     HTML::Embperl::ScanEnvironment;
> 
>     HTML::EmbperlObject::Execute ({inputfile => 'table.ep'});
>     HTML::EmbperlObject::Execute ({inputfile => 'title.ep'});
> 
>     print end_html();
> }
> 
> file table.ep:
> [- @link = (
> "1",
> "2"
> ) -]
> 
> [- @name = (
> "1",
> "2"
> ) -]
> 
> start table
> [- $i = 0 -]
> <table border=0 cellpadding=3 cellspacing=0 width=100%>
> [$ do $]
>     <tr><td>
>         <table border=0 cellpadding=1 cellspacing=0 width=100%
> bgcolor=#6699cc> <tr><td>
>             <table border=0 cellpadding=5 cellspacing=0 width=100%
> bgcolor=#e7effa> <tr><td>
>                 <a href=[+ $link[ $i ] +]><b>[+ $name[ $i ] +]</b></a>
>             </td></tr> </table>
>         </td></tr> </table>
>     </td></tr>
> [- $i++ -]
> [$ until $i > $#link $]
> </table>
> end table
> 
> file title.ep:
> <h2>
>        [- @time = split /[\s:]/, localtime; -]
>        [$ if ( $time[3] < 12 ) $]
>        Good morning
>        [$ elsif ( $time[3] < 17 ) $]
>        Good afternoon
>        [$ else $]
>        Good evening
>        [$ endif $]
> </h2>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org


You might want to check EmbperlObj docs:
http://perl.apache.org/embperl/EmbperlObject.pod.cont.html


Dimitri Ostapenko
Perl/Internet

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org