Mailing List Archive

Beginner's question
Hi!

I've read docs about using embperl and HTML escaping, I tried to display e.g.
forms data (it works fine), but I still don't know, how to embedd such a simple
code in html page:

open(FILE,"</path/to/file");
while(<FILE>) {
print;
}

Could anybody help me?

T.I.A.

--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl
RE: Beginner's question [ In reply to ]
On 14-Jun-2000 Ryszard Lach wrote:
> Hi!
>
> I've read docs about using embperl and HTML escaping, I tried to display e.g.
> forms data (it works fine), but I still don't know, how to embedd such a
> simple
> code in html page:
>
> open(FILE,"</path/to/file");
> while(<FILE>) {
> print;
> }
>
> Could anybody help me?

[- open FILE, "/path/to/file" -]
[$ while <FILE> $]
[+ $_ +]
[$ endwhile $]


--
Jason Bodnar + jbodnar@team-linux.com + Team Linux

Homer: We always have one good kid and one lousy kid. Why can't both
our kids be good?

Marge: We have three kids, Homer.

Separate Vacations
Re: Beginner's question [ In reply to ]
Try:

[.-
open(FILE,"</path/file") || die "Can't open file";
$escmode = 0; # needed for the subsequent print in "while"
# otherwise Embperl will complain
while(<FILE>){
print;
}
$escmode = 1;
close(FILE);
-]

Ryszard Lach wrote:
>
> Hi!
>
> I've read docs about using embperl and HTML escaping, I tried to display e.g.
> forms data (it works fine), but I still don't know, how to embedd such a simple
> code in html page:
>
> open(FILE,"</path/to/file");
> while(<FILE>) {
> print;
> }
>
> Could anybody help me?
>
> T.I.A.
>
> --
> Ryszard £ach
> Internet Designers s.c.
> http://www.id.pl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org

--
__________________________________________________________
Mr. Erich L. Markert emarkert@pace.edu
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
Re: Beginner's question [ In reply to ]
$escmode has nothing to do with being able to use print() inside [- -]. In
order to do that you have to turn on optRedirectStdout as part of your
EMBPERL_OPTIONS in your conf file.

On 14-Jun-2000 Erich L. Markert wrote:
> Try:
>
> [.-
> open(FILE,"</path/file") || die "Can't open file";
> $escmode = 0; # needed for the subsequent print in "while"
> # otherwise Embperl will complain
> while(<FILE>){
> print;
> }
> $escmode = 1;
> close(FILE);
> -]
>
> Ryszard Lach wrote:
>>
>> Hi!
>>
>> I've read docs about using embperl and HTML escaping, I tried to display
>> e.g.
>> forms data (it works fine), but I still don't know, how to embedd such a
>> simple
>> code in html page:
>>
>> open(FILE,"</path/to/file");
>> while(<FILE>) {
>> print;
>> }
>>
>> Could anybody help me?
>>
>> T.I.A.
>>
>> --
>> Ryszard £ach
>> Internet Designers s.c.
>> http://www.id.pl
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
>> For additional commands, e-mail: embperl-help@perl.apache.org
>
> --
> __________________________________________________________
> Mr. Erich L. Markert emarkert@pace.edu
> Computer Learning Center TEL (914)422-4328
> Pace University
> 1 Martine Ave
> White Plains, New York 10606-1932
>
> Those who do not understand Unix are condemned to reinvent it, poorly.
> -- Henry Spencer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org

--
Jason Bodnar + jbodnar@team-linux.com + Team Linux

Homer: I keep hearing this horrible irregular thumping noise.

Pump Jockey:
It's your heart. And I think it's on its last thump.

Homer: Whew, I was afraid it was my transmission.

Homer's Triple Bypass
Re: Beginner's question [ In reply to ]
Yep, my mistake.

jbodnar@team-linux.com wrote:
>
> $escmode has nothing to do with being able to use print() inside [- -]. In
> order to do that you have to turn on optRedirectStdout as part of your
> EMBPERL_OPTIONS in your conf file.
>
> On 14-Jun-2000 Erich L. Markert wrote:
> > Try:
> >
> > [.-
> > open(FILE,"</path/file") || die "Can't open file";
> > $escmode = 0; # needed for the subsequent print in "while"
> > # otherwise Embperl will complain
> > while(<FILE>){
> > print;
> > }
> > $escmode = 1;
> > close(FILE);
> > -]
> >
> > Ryszard Lach wrote:
> >>
> >> Hi!
> >>
> >> I've read docs about using embperl and HTML escaping, I tried to display
> >> e.g.
> >> forms data (it works fine), but I still don't know, how to embedd such a
> >> simple
> >> code in html page:
> >>
> >> open(FILE,"</path/to/file");
> >> while(<FILE>) {
> >> print;
> >> }
> >>
> >> Could anybody help me?
> >>
> >> T.I.A.
> >>
> >> --
> >> Ryszard £ach
> >> Internet Designers s.c.
> >> http://www.id.pl
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> >> For additional commands, e-mail: embperl-help@perl.apache.org
> >
> > --
> > __________________________________________________________
> > Mr. Erich L. Markert emarkert@pace.edu
> > Computer Learning Center TEL (914)422-4328
> > Pace University
> > 1 Martine Ave
> > White Plains, New York 10606-1932
> >
> > Those who do not understand Unix are condemned to reinvent it, poorly.
> > -- Henry Spencer
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
>
> --
> Jason Bodnar + jbodnar@team-linux.com + Team Linux
>
> Homer: I keep hearing this horrible irregular thumping noise.
>
> Pump Jockey:
> It's your heart. And I think it's on its last thump.
>
> Homer: Whew, I was afraid it was my transmission.
>
> Homer's Triple Bypass

--
__________________________________________________________
Mr. Erich L. Markert emarkert@pace.edu
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
RE: Beginner's question [ In reply to ]
Hey u can even use this way specifying the file in embperl page ...
[- Execute ('/appls/com/includes/pz5551234navBar.txt') -]
but it is avaialble after Embperl version 1.2b4 only ...so check that out
...

rgds
Gopi

-----Original Message-----
From: Ryszard Lach [mailto:siaco@id.pl]
Sent: Wednesday, June 14, 2000 5:34 PM
To: embperl@perl.apache.org
Subject: Beginner's question


Hi!

I've read docs about using embperl and HTML escaping, I tried to display
e.g.
forms data (it works fine), but I still don't know, how to embedd such a
simple
code in html page:

open(FILE,"</path/to/file");
while(<FILE>) {
print;
}

Could anybody help me?

T.I.A.

--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Beginner's question [ In reply to ]
On Wed, Jun 14, 2000 at 12:45:06PM -0400, Erich L. Markert wrote:
> Try:
>
> [.-
> open(FILE,"</path/file") || die "Can't open file";
> $escmode = 0; # needed for the subsequent print in "while"
> # otherwise Embperl will complain
> while(<FILE>){
> print;
> }
> $escmode = 1;
> close(FILE);
> -]

Well the following did work:

open (FILE, "\</path/file") or die;

while (\<FILE>) {
print OUT $_;
}

But a little bit different:

open (FILE, "/path/command \</path/file |") or die;

while (\<FILE>) {
print OUT $_;
}

did not. I received Internal Server Error and the following in apache's error
log:

[Thu Jun 15 17:42:39 2000] [error] [client 192.168.1.66] malformed header from
script. Bad header=<table>: /usr/lib/cgi-bin/embpcgi.pl

what means, embperl skipped all html stuff inserted before script part. Do you
have any ideas?


Siaco.

--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl
RE: Beginner's question [ In reply to ]
>
> open (FILE, "/path/command \</path/file |") or die;
>
> while (\<FILE>) {
> print OUT $_;
> }
>
> did not. I received Internal Server Error and the following in
> apache's error
> log:
>
> [Thu Jun 15 17:42:39 2000] [error] [client 192.168.1.66]
> malformed header from
> script. Bad header=<table>: /usr/lib/cgi-bin/embpcgi.pl
>
> what means, embperl skipped all html stuff inserted before script
> part. Do you
> have any ideas?
>

I would guess it's the other way round. Your command has, for whatever
reasons, printed directly to stdout (and that will come out before the
output from Embperl), instead of the redirection to <FILE>.

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 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
Re: Beginner's question [ In reply to ]
On Fri, Jun 16, 2000 at 08:41:18AM +0200, Gerald Richter wrote:
> >
> > open (FILE, "/path/command \</path/file |") or die;
> >
> > while (\<FILE>) {
> > print OUT $_;
> > }
> >
> > did not. I received Internal Server Error and the following in
> > apache's error
> > log:
> >
> > [Thu Jun 15 17:42:39 2000] [error] [client 192.168.1.66]
> > malformed header from
> > script. Bad header=<table>: /usr/lib/cgi-bin/embpcgi.pl
> >
> > what means, embperl skipped all html stuff inserted before script
> > part. Do you
> > have any ideas?
> >
>
> I would guess it's the other way round. Your command has, for whatever
> reasons, printed directly to stdout (and that will come out before the
> output from Embperl), instead of the redirection to <FILE>.

Well, I wouldn't say so. In this case the output would be seeable before static
html tags, but it isn't.

Look at this complete page code:

########################
<html>
<head>
<title>Statystyki poczty - summary of senders</title>
</head>

<body>
[.-
$escmode = 0;
open(FILE, "/usr/local/qmailanalog/bin/zsenders
\</var/log/qmail/qmail.log|") or die "Cant open file";
while(\<FILE>) {
if ( m/^mess\s+/ ){
print OUT $_,"<br>";
next;
}
else {
print "\<table>\n";
$_ =~ s/\s+/\<td>/g;
print OUT "\<tr>\<td>$_\<br>\n";
last;
}
}

while ( \<FILE> ) {
$_ =~ s/\</&lt;/g;
$_ =~ s/>/&gt;/;
$_ =~ s/^\s*/\<td>/;
$_ = s/\s+/\<td>/;
PRINT OUT "\<tr>",$_,"\n";
}

print "\</table>";
$escmode = 1;
-]
</body>
</html>
########################

This page produces (by embpexec.pl):

<table>
</table><html>
<head>
<title>Statystyki poczty - summary of senders</title>
</head>

<body>
<tr><td><br>
</body>
</html>
############################

What is wrong with it? How can I debug this?

Siaco.


--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl
RE: Beginner's question [ In reply to ]
> print "\<table>\n";

print OUT "\<table>\n";
...

>
> print "\</table>";

print OUT "\</table>";

or set optRedirectStdout in your EMBPERL_OPTIONS

Gerald
Re: Beginner's question [ In reply to ]
On Fri, Jun 16, 2000 at 09:54:53AM +0200, Gerald Richter wrote:
> > print "\<table>\n";
>
> print OUT "\<table>\n";
> ...
>
> >
> > print "\</table>";
>
> print OUT "\</table>";
>
> or set optRedirectStdout in your EMBPERL_OPTIONS

OK, now it works, thanks.

Does the same concern opening pipes (i.e. commands, not named pipes) as files?

open(FILE,"cat \</etc/passwd |")
while (\<FILE>) {
print OUT $_;
}

doesn't produce any output....

--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl
RE: Beginner's question [ In reply to ]
>
> Does the same concern opening pipes (i.e. commands, not named
> pipes) as files?
>
> open(FILE,"cat \</etc/passwd |")
> while (\<FILE>) {
> print OUT $_;
> }
>
> doesn't produce any output....
>

Embperl makes no difference here, but you may check the return value from
open and $! . Maybe you don't have permission to execute cat as www server
user, or cat is not in your path.

Gerald
Re: Beginner's question [ In reply to ]
Some things to notice...

In your code you have: "qmail.log|" in your open() statement - I don't
think you want that if you are simply reading the file.

Also, ALWAYS, ALWAY, ALWAYS close file handles via close() if you are
using open().

Ryszard Lach wrote:
>
> On Fri, Jun 16, 2000 at 08:41:18AM +0200, Gerald Richter wrote:
> > >
> > > open (FILE, "/path/command \</path/file |") or die;
> > >
> > > while (\<FILE>) {
> > > print OUT $_;
> > > }
> > >
> > > did not. I received Internal Server Error and the following in
> > > apache's error
> > > log:
> > >
> > > [Thu Jun 15 17:42:39 2000] [error] [client 192.168.1.66]
> > > malformed header from
> > > script. Bad header=<table>: /usr/lib/cgi-bin/embpcgi.pl
> > >
> > > what means, embperl skipped all html stuff inserted before script
> > > part. Do you
> > > have any ideas?
> > >
> >
> > I would guess it's the other way round. Your command has, for whatever
> > reasons, printed directly to stdout (and that will come out before the
> > output from Embperl), instead of the redirection to <FILE>.
>
> Well, I wouldn't say so. In this case the output would be seeable before static
> html tags, but it isn't.
>
> Look at this complete page code:
>
> ########################
> <html>
> <head>
> <title>Statystyki poczty - summary of senders</title>
> </head>
>
> <body>
> [.-
> $escmode = 0;
> open(FILE, "/usr/local/qmailanalog/bin/zsenders
> \</var/log/qmail/qmail.log|") or die "Cant open file";
> while(\<FILE>) {
> if ( m/^mess\s+/ ){
> print OUT $_,"<br>";
> next;
> }
> else {
> print "\<table>\n";
> $_ =~ s/\s+/\<td>/g;
> print OUT "\<tr>\<td>$_\<br>\n";
> last;
> }
> }
>
> while ( \<FILE> ) {
> $_ =~ s/\</&lt;/g;
> $_ =~ s/>/&gt;/;
> $_ =~ s/^\s*/\<td>/;
> $_ = s/\s+/\<td>/;
> PRINT OUT "\<tr>",$_,"\n";
> }
>
> print "\</table>";
> $escmode = 1;
> -]
> </body>
> </html>
> ########################
>
> This page produces (by embpexec.pl):
>
> <table>
> </table><html>
> <head>
> <title>Statystyki poczty - summary of senders</title>
> </head>
>
> <body>
> <tr><td><br>
> </body>
> </html>
> ############################
>
> What is wrong with it? How can I debug this?
>
> Siaco.
>
> --
> Ryszard £ach
> Internet Designers s.c.
> http://www.id.pl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org

--
__________________________________________________________
Mr. Erich L. Markert emarkert@pace.edu
Computer Learning Center TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
Re: Beginner's question [ In reply to ]
On Fri, Jun 16, 2000 at 02:12:48PM +0200, Gerald Richter wrote:
> >
> > Does the same concern opening pipes (i.e. commands, not named
> > pipes) as files?
> >
> > open(FILE,"cat \</etc/passwd |")
> > while (\<FILE>) {
> > print OUT $_;
> > }
> >
> > doesn't produce any output....
> >
>
> Embperl makes no difference here, but you may check the return value from
> open and $! . Maybe you don't have permission to execute cat as www server
> user, or cat is not in your path.

No, that is not the proble, because:

1. This was a simpler example, in fact I tried to use


open (FILE, "/usr/local/qmailanalog/bin/zsenders \</var/log/qmail/qmail.log |") or die;

(Sorry for this change, the version with cat was written quickly just to be
sure, that qmailanalog is not the problem)

2. "/usr/local/qmailanalog/bin/zsenders \</var/log/qmail/qmail.log |"

was executed without problems from within php3 script....

Once more, wat is happening with following example:



open(FILE,"/bin/cat \</etc/passwd |") or die;
while (\<FILE>) {
print OUT $_;
}

causes browser to wait indefinitly long for reply.

Any more ideas?

--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl
Re: Beginner's question [ In reply to ]
On Fri, Jun 16, 2000 at 08:35:03AM -0400, Erich L. Markert wrote:
> Some things to notice...
>
> In your code you have: "qmail.log|" in your open() statement - I don't
> think you want that if you are simply reading the file.

No, I'm not reading the file, I'm reading output form


/path/command </path/stdin_to_this_command |

pipe.

> Also, ALWAYS, ALWAY, ALWAYS close file handles via close() if you are
> using open().

OK, OK, I always do close files (this time was a bad exception), and adding
close(FILE) didn't help....

>
> Ryszard Lach wrote:
> >
> > On Fri, Jun 16, 2000 at 08:41:18AM +0200, Gerald Richter wrote:
> > > >
> > > > open (FILE, "/path/command \</path/file |") or die;
> > > >
> > > > while (\<FILE>) {
> > > > print OUT $_;
> > > > }
> > > >
> > > > did not. I received Internal Server Error and the following in
> > > > apache's error
> > > > log:
> > > >
> > > > [Thu Jun 15 17:42:39 2000] [error] [client 192.168.1.66]
> > > > malformed header from
> > > > script. Bad header=<table>: /usr/lib/cgi-bin/embpcgi.pl
> > > >
> > > > what means, embperl skipped all html stuff inserted before script
> > > > part. Do you
> > > > have any ideas?
> > > >
> > >
> > > I would guess it's the other way round. Your command has, for whatever
> > > reasons, printed directly to stdout (and that will come out before the
> > > output from Embperl), instead of the redirection to <FILE>.
> >
> > Well, I wouldn't say so. In this case the output would be seeable before static
> > html tags, but it isn't.
> >
> > Look at this complete page code:
> >
> > ########################
> > <html>
> > <head>
> > <title>Statystyki poczty - summary of senders</title>
> > </head>
> >
> > <body>
> > [.-
> > $escmode = 0;
> > open(FILE, "/usr/local/qmailanalog/bin/zsenders
> > \</var/log/qmail/qmail.log|") or die "Cant open file";
> > while(\<FILE>) {
> > if ( m/^mess\s+/ ){
> > print OUT $_,"<br>";
> > next;
> > }
> > else {
> > print "\<table>\n";
> > $_ =~ s/\s+/\<td>/g;
> > print OUT "\<tr>\<td>$_\<br>\n";
> > last;
> > }
> > }
> >
> > while ( \<FILE> ) {
> > $_ =~ s/\</&lt;/g;
> > $_ =~ s/>/&gt;/;
> > $_ =~ s/^\s*/\<td>/;
> > $_ = s/\s+/\<td>/;
> > PRINT OUT "\<tr>",$_,"\n";
> > }
> >
> > print "\</table>";
> > $escmode = 1;
> > -]
> > </body>
> > </html>
> > ########################
> >
> > This page produces (by embpexec.pl):
> >
> > <table>
> > </table><html>
> > <head>
> > <title>Statystyki poczty - summary of senders</title>
> > </head>
> >
> > <body>
> > <tr><td><br>
> > </body>
> > </html>
> > ############################
> >
> > What is wrong with it? How can I debug this?
> >
> > Siaco.
> >
> > --
> > Ryszard ?ach
> > Internet Designers s.c.
> > http://www.id.pl
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
>
> --
> __________________________________________________________
> Mr. Erich L. Markert emarkert@pace.edu
> Computer Learning Center TEL (914)422-4328
> Pace University
> 1 Martine Ave
> White Plains, New York 10606-1932
>
> Those who do not understand Unix are condemned to reinvent it, poorly.
> -- Henry Spencer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>

--
Ryszard £ach
Internet Designers s.c.
http://www.id.pl
RE: Beginner's question [ In reply to ]
> >
> > open(FILE,"/bin/cat \</etc/passwd |") or die;
> > while (\<FILE>) {
> > print OUT $_;
> > }
> >
>
Have you set optRawInput ? If not try

while (&lt;FILE&gt;) {

Gerald