Solved

Include external files w/o layers?

Posted on 1998-10-28
30
167 Views
Last Modified: 2013-11-18
Is it possible to add  external files to a document, in the same manner as an include virtual-tag, but from another server? I do not wish to use frames, nor layers, since it must work on at least Navigator 301, preferrably 201, i.e. no strange Microsoft solutions either... But cgi-scripting is OK.
If this could be worked out i will add more points for a functional solution.
/Fischier
0
Comment
Question by:fischier
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 8
  • 8
  • +1
30 Comments
 
LVL 4

Expert Comment

by:martinag
ID: 1839124
Using the well-known
<!--#include --> I don't know if it is possible.

One could write a simple script though. My only problem is that I have no possibility of testing it...
I'll give it a shot anyway. It's perl and should be saved as .pl, eg "getdoc.pl"

#!/usr/bin/perl

use IO::Socket;
$site = 'some.where.com"; // Change this...
$http_port=80;
$url = "http://some.where.com/some/path.html"; // ...and this

$them = IO::Socket::INET->new(
                              Proto    => "tcp",
                              PeerAddr => $site,
                              PeerPort => $http_port,
                              )
or die "cannot connect to http server $site:$$http_port";
print $them "GET $url HTTP/1.0\n\n";
@entire_page=  <$them>;
close $them or die "cannot close connection: $!";

print STDOUT "Content-Type: text/plain\n\n@entirepage";

---

Then call it from your .stm:
<!--#exec cgi="getdoc.pl" -->

Martin
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1839125
You can also use the OBJECT tag.

<OBJECT DATA="yourfile.htm" WIDTH=500 HEIGHT=100></OBJECT>

This will load the "yourfile.htm" into an object box.
0
 
LVL 4

Expert Comment

by:martinag
ID: 1839126
I see now that
print STDOUT "Content-Type: text/plain\n\n@entirepage";
should be
print STDOUT "Content-Type: text/plain\n\n@entire_page";

Martin
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:martinag
ID: 1839127
MasseyM, is that an IE4 tag? I've never heard of it before.

Martin
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1839128
OBJECT is an HTML 3.0 standard tag developed by the W3 Consortium...  http://www.w3.org

0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1839129
OBJECT is an HTML 3.0 standard tag developed by the W3 Consortium...  http://www.w3.org
0
 
LVL 4

Expert Comment

by:martinag
ID: 1839130
I see. Thanks.

Martin
0
 
LVL 1

Author Comment

by:fischier
ID: 1839131
Thanks, but this is a bit over my head. Could you please clean it to a runnable script, preferrably with comments?
/Fischier
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1839132
To include a file, use this:

<OBJECT DATA="filename.htm" WIDTH=150 HEIGHT=200></OBJECT>

This will create a "box" on your page with the file 'filename.htm' loaded in it.  IT is VERY simple.
0
 
LVL 1

Author Comment

by:fischier
ID: 1839133
I'm sorry, i can't get this to work, neither with Navigator 301, 405 nor Explorer.
Any ideas what i'm doing wrong?
/F
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839134
MasseyM, HTML 3.0 was never accepted and many of the things are not supported. Your IE only object tag might embed a new IE web browser but I have never seen this in real life.
IE3+ supports the
<IFRAME SRC="filename.htm" WIDTH=300 HEIGHT=500></IFRAME>

but Netscape 2.0, IE3.0 and OPERA 2.?? all support frames so why not just use that?

Michel
0
 
LVL 1

Author Comment

by:fischier
ID: 1839135
Well Michel, i was trying to avoid using frames since we've been having terrible problems with downloading times, besides, since it has to be a scrollable page, i'd have to live with scrolling bars in the middle of the window, which i sincerely dislike.
I haven't tried Martins CGI-suggestion, would it work, and what would i have to do?
/Fischier
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839136
Martin has suggested a socket solution. That will always work (if  your cgi can convince the foreign site to give you the data...) even in mosaic 1.0 (unless the html itself is complex)
You will need cgi access and perl installed on the web server (in the above example - other programming languages like c can also be used...)

Michel
0
 
LVL 1

Author Comment

by:fischier
ID: 1839137
I have CGI-access and perl installed, how would i proceed, and would the whole document have to be created on the fly? Also: how great a security risk would this script be?
/F
0
 
LVL 4

Expert Comment

by:martinag
ID: 1839138
Put the code I gave you in a file called getPage.pl.

Make sure that the first line points to perl if you're on UNIX, otherwise you don't have to care about that.

Replace this:
$site = 'some.where.com"; // Change this...
$http_port=80;
$url = "http://some.where.com/some/path.html"; // ...and this
with this:
$site = "some.where.com"; # Change this...
$http_port=80;
$url = "http://some.where.com/some/path.html"; # ...and this

Also, you must change the strings' values in order to download the right document from the right server.

In your HTML, put this where it should be inserted:
<!--#exec cgi="/cgi-bin/getFile.pl"-->

If you're on a UNIX you must chmod the script 666.

About security, it much depends on the server. The script itself is secure but if your server isn't, someone with knowledge enough could change the script in order to change/delete important files, download password files or just be a pain in the ass.

Martin
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839139
Fishier: Martins solution does not have to be restricted to SSI (Server Side Include) - it can also be just a normal cgi with a

print STDOUT "Content-Type: text/html\n\n"
as the first statement, the outputting of a local html 'header'
output of @entire_page and then output of
local html 'footer'

The foreign file might need to have some tags removed by the way (<BODY> in a frame set or vice versa)

I am sure Martin can add this if needed.

Be sure to understand any copyright issues.

Michel
0
 
LVL 1

Author Comment

by:fischier
ID: 1839140
Hi Martin, i tried it but i'm only getting "[an error occurred while processing this directive] ". i tried chmodding it up to 777, set parsing to exec, but to no avail.

This is what the script looks like:
                #!/usr/bin/perl

                use IO::Socket;
             
                $site = "www.ettnet.se"; # Change this...
                $http_port=80;
                $url = "http://www.ettnet.se/~boris/1950s.html"; # ...and this

                $them = IO::Socket::INET->new(
                                              Proto    => "tcp",
                                              PeerAddr => $site,
                                              PeerPort => $http_port,
                                              )
                or die "cannot connect to http server $site:$$http_port";
                print $them "GET $url HTTP/1.0\n\n";
                @entire_page=  <$them>;
                close $them or die "cannot close connection: $!";

                print STDOUT "Content-Type: text/plain\n\n@entire_page";


Tag is: <!--#exec cgi="http://www.gp.se/cgi-bin/getPage.pl"-->
(not getFile.pl )    ;-)

I'm running out of ideas, unless our firewall is making the fuss... but both script and file is outside it...
/T
0
 
LVL 1

Author Comment

by:fischier
ID: 1839141
Michel: Could <BODY> etc be the reason for an error message?
I'm also trying to force the external page into a Table... could this affect the result?
/F
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839142
I doubt it.
The error message probably comes from the web server so I would try the following:

1. Run the program from the commandline on the server and see if there are error messages. If yes, fix them.

2. Is the web server owner/member of the group that owns the perl file (chown)
I get GP har inte funnit sidan if I try to load http://www.gp.se/cgi-bin/getPage.pl from the location bar

3. Is http://www.ettnet.se/~boris/1950s.html available?

2. Is exec ssi enabled on the server? Could be that #exec is not allowed (quite often it is not) but i suspect a typo or script error but I do not do perl in that much detail...

Michel
0
 
LVL 1

Author Comment

by:fischier
ID: 1839143
Well, i'm a bit dubious about using exec anyway... I still can't get it to work, but i'd be willing to award Martin his points anyway, and i'll keep working on it.
/Fischier
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839144
If you call your cgi in a link or in a form, it would not need SSI exec
The cgi would just need to output the complete page including the stuff from the foreign page...

First get the cgi to run from the comand line, then the rest should be a matter of web server settings/chmod/chown

Michel
0
 
LVL 4

Expert Comment

by:martinag
ID: 1839145
Michel have answered all of your questions.
If your server doesn't support <!--#exec--> just let me now and I'll add a few lines to the script.

Martin
0
 
LVL 1

Author Comment

by:fischier
ID: 1839146
Michel: Thanks a lot, as always your knowledge is dazzling.
Martin: Yes please, i'd prefer to run the script w/o exec activated. Could you give me a runnable script?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839147
Glad to be of service.

Michel
0
 
LVL 4

Expert Comment

by:martinag
ID: 1839148
#!/usr/bin/perl

# Get extern file
use IO::Socket;
$site = "www.ettnet.se";
$http_port=80;
$url = "http://www.ettnet.se/~boris/1950s.html";

$them = IO::Socket::INET->new(
  Proto    => "tcp",
  PeerAddr => $site,
  PeerPort => $http_port,
) or die "cannot connect to http server $site:$$http_port";

print $them "GET $url HTTP/1.0\n\n";

$externfile = "";
while (<$them>) {
  $externfile .= $_;
}

close $them or die "cannot close connection: $!";

# I take it you only want the stuff between <BODY> and </BODY>.
$title = "none";
$externfile =~ s/<TITLE>(.*?)<\/TITLE>/$title=$1;"<TITLE>$1<\/TITLE>";/e;
$externfile =~ s/.*<BODY.*?>//;
$externfile =~ s/<\/BODY.*?>.*//;

# Get local file and paste the extern into it
open (FILE, "<local.htm") or die "open file: $!";
$localfile = "";
$localfile .= $_ while <FILE>;
close FILE;
$localfile =~ s/<!-- insert extern file -->/<!-- begin extern file (Title: $title) -->\n$externfile\n<!-- end extern file -->/;

# Return
print "Content-Type: text/html\nPragma: no-cache\n\n$localfile";

---

Replace local.htm with the name of the file that should be read. Then call the script like any file at all:
<A HREF="theScript.pl">A page</A>

Martin
0
 
LVL 1

Author Comment

by:fischier
ID: 1839149
Well, to whom am i going to award the points?
Do you wish for me to split it?
/F
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839150
That would be nice! I think Martin should answer :-)

Michel
0
 
LVL 4

Accepted Solution

by:
martinag earned 200 total points
ID: 1839151
All right...

If you want to give Michel, Massey or maybe both some points you can ask linda in the Customer Service area and you won't have to pay any extra points. I don't think so at least.

Martin
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1839152
No extra points needed to split points between experts

Michel
0
 
LVL 1

Author Comment

by:fischier
ID: 1839153
Just waiting for reply from Linda.'
/F
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question