How to sort and how to show cgi output into an iframe?

V

V S Rawat

I have put a website search form on my home page. it has just a textarea
in which the term(s) to be searched are entered and then submit button
calls the perlscript that is finding that term in all files in the
website and showing the links of those files in which the term is
present. It is working correctly.

Two issues:

1. Perl is either checking files in the order of their filenames or in
the order in which it finds them in the folder, so the results are not
coming sorted. One menu branch items are coming scattered within other
menu branches items.

How can I sort it out so that at least one menu branch comes together?

2. The submit button is on the main home page.

all other links on the homepage are showing their results into an iframe
in the middle, using target="iframe"

but perl generated page comes standalone.

How can I show the results of this submit into the iframe?

thanks.
 
V

V S Rawat

I have put a website search form on my home page. it has just a textarea
in which the term(s) to be searched are entered and then submit button
calls the perlscript that is finding that term in all files in the
website and showing the links of those files in which the term is
present. It is working correctly.

Two issues:

1. Perl is either checking files in the order of their filenames or in
the order in which it finds them in the folder, so the results are not
coming sorted. One menu branch items are coming scattered within other
menu branches items.

How can I sort it out so that at least one menu branch comes together?

2. The submit button is on the main home page.

all other links on the homepage are showing their results into an iframe
in the middle, using target="iframe"

but perl generated page comes standalone.

How can I show the results of this submit into the iframe?

thanks.


my gawd. So simple. And I spent so long thinking out what to do.

form target="iframe" shows the result of perl into iframe.

The company of this ng made me wise. :) thanks.
 
V

V S Rawat

my gawd. So simple. And I spent so long thinking out what to do.

form target="iframe" shows the result of perl into iframe.

The company of this ng made me wise. :) thanks.

Further, how to find whether my server supports SSI or not?

to avoid generating entire html through perl, I have created an html
file of the header part that remains common across the perl script results.

I want to include it in my result and then add whatever perl generates
along with footer.

How to give that command in my perlscript?

I have added in my perlscript
print "<!--#include file=\"index_search_include.txt\"-->\n";
where index_search_include.txt is the header file that I have made.

but server is giving 500 internal server error and error logs are showing

malformed header from script. Bad header=<!--#include file="index_searc:
/home/username/public_html/cgi-bin/search.cgi

where to put that index_search_include.txt file? in cgi-bin or in
public_html or where, and what name to include? just the file name or
even the path /home/username/public_html/index_search_include.txt

there was also some issue that .html is to be renamed to .shtml for ssi
to work. I couldn't understand which .html file to rename.

if server doesn't support html, I would need to generate entire thing
line by line through perl or to read from that file and write thru perl.

Thanks.
 
S

smallpond

my gawd. So simple. And I spent so long thinking out what to do.

form target="iframe" shows the result of perl into iframe.

The company of this ng made me wise. :) thanks.

You are getting the files in the order in which they appear in
the directory. To sort them:

1. read all the filenames into an array @filenames
2. to send the output to your page, loop thru the array using foreach
foreach (sort {$a cmp $b} @filenames)
3. to modify the order of the output, change {$a cmp $b} to a
different function.

To put all of the subdirectories first, for example, you will want to
test using '-d' and change the result of the comparison accordingly.

--S
 
V

V S Rawat

Further, how to find whether my server supports SSI or not?

ok, when I upload the following in a file to my server, and open in
browser, I do see Monday. that means SSI is working for me. but not in
html file. it worked in shtml file.

<HTML>
<TITLE>Test File</TITLE>

<!--#config timefmt="%A" --> <!--#echo var="DATE_LOCAL" -->

</HTML>
 
S

sln

Further, how to find whether my server supports SSI or not?

to avoid generating entire html through perl, I have created an html
file of the header part that remains common across the perl script results.

I want to include it in my result and then add whatever perl generates
along with footer.

How to give that command in my perlscript?

I have added in my perlscript
print "<!--#include file=\"index_search_include.txt\"-->\n";
where index_search_include.txt is the header file that I have made.

but server is giving 500 internal server error and error logs are showing

malformed header from script. Bad header=<!--#include file="index_searc:
/home/username/public_html/cgi-bin/search.cgi

where to put that index_search_include.txt file? in cgi-bin or in
public_html or where, and what name to include? just the file name or
even the path /home/username/public_html/index_search_include.txt

If you generate, or get some portion of your html with perl, then pass
it on, you can do any sort of amalgomation you wan't.

It seams as though you are forcing the html through a processor that
won't take incomplete html.

You many need a perl script that joins html fragments into a whole
before sending it to the renderer.

You can do it one of two ways, insert the placeholder in the constant html
or insert it into the dynamic part, substitute, then send it to the renderer.

This avoids generating html because you are using constant html as the substitute,
and just printing out the joined parts. Since this is by design, there should be no
errors as long as the reconstituted whole does not have errors (which can be checked
before the renderer gets it).

This can be done by hand like mail merge substitution or you can use a reliable
capture parser (or do it all in ASP?):

=========================
use strict;
use warnings;

use RXParse; # VERSIN 2

my $p = new RXParse();
$p->setMode( 'html' => 1, 'resume_onerror'=> 1 );
$p->setHandlers('start' => \&starth, 'end' => \&endh);

sub starth
{
my ($obj, $el, $term, @attr) = @_;
my $buffer = lc($el);
if ($buffer eq 'substitutebody' || $buffer eq 'substitutefooter')
{
$obj->CaptureOn( $buffer );
}
}
sub endh
{
my ($obj, $el, $term) = @_;
my $buffer = lc($el);
if ($buffer eq 'substitutebody' || $buffer eq 'substitutefooter')
{
$obj->CaptureOff( $buffer, 1 );
}
}

open my $fh, 'c:\temp\header_footr.html' or die "can't open header_footr.html...";

$p->CaptureOn('ALL');
$p->parse($fh);
$p->CaptureOff('ALL');

close $fh;

$p->DumpCaptureBuffs();

# generate dynamic html
# ...

# substitute the capture sequence body for the dynamic html generated.
# the sequence is just the index into the main capture array.
# this is all 'raw' html. functions are provided for this though.
# ....

# write/send out the entire sequence now as complete html
# ...



__END__



BUFFER: all
=====================================
index seqence
----- --------
[0] 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head><title>CNN.com - Breaking News, U.S., World, Weather,
Entertainment & Video News</title>
<meta http-equiv="refresh" content="1800;url=?refresh=1">
<meta name="Description" content="CNN.com delivers the latest breaking news and information on the latest top stories, weather, business, entertainment, politics, and more. For in-depth coverage,
CNN.com provides special reports, video, audio, photo galleries, and interactive guides.">
<meta name="Keywords" content="CNN, CNN news, CNN.com, CNN TV, news, news online, breaking news, U.S. news, world news, weather, business, CNN Money, sports, politics, law, technology, entertainment,
education, travel, health, special reports, autos, developing story, news video, CNN Intl">
</head>
[1] -2
[2] 3 undefined
[3] -4
[4] 5 </html>


BUFFER: substitutebody
=====================================
index seqence
----- --------
[0] 2 <substitutebody DROP YOUR BODY IN THIS SEQUENCE></substitutebody>


BUFFER: substitutefooter
=====================================
index seqence
----- --------
[0] 4 <substitutefooter DROP YOUR FOOTER IN THIS SEQUENCE></substitutefooter>
 
J

Jürgen Exner

V S Rawat said:
Two issues:
1. Perl is either checking files in the order of their filenames or in
the order in which it finds them in the folder, so the results are not
coming sorted.

Perl simply uses whatever the operating system returns. If the OS
returns them in random sequence, then Perl will just use that sequence.
How can I sort it out so that at least one menu branch comes together?

If you want file names to be sorted by some criteria, then you need to
sort them yourself. See "perldoc -f sort".

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top