Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INCLUDE remote file 1

Status
Not open for further replies.
You cannot incluse cross servere in this fashion-

You need to use javascript

document.write("
Although you'd need to check that syntax.

Remeber though that javascript tend to be temporamental and your file would all need to be on one line in a text editor, as javascript may not read the entire file and bring up an error Caspar Kennerdale
Senior Media Developer
 
I doubt you'd have much success using JavaScript. You can't simply write() it. You'd have to set the layer.src in NS and an iframe or hidden frame in IE. That's a major pain in the butt.

What you want to do is use CGI. It would be fairly simple to write a Perl script which reads the external file and prints it out into your HTML page.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
I'm gonna try both ideas. Thank you very much!
 
Well you can do this, but not quite the way I said.
(sorry a late night!!);

You are using javascript to write a file which has the document.write code in it.

This is very useful for including files cross servers in a quick fix manner or withou databasing or perl knowledge.

And a lot quicker.

Here is the code for the two files-

// (1) Main Page displaying remote file- target.html

<html>
<head>
<title>The Tuckshop.com File Include Script</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body >
<script language=&quot;JavaScript&quot; src=&quot;</body>
</html>

// (2) Include File- index.php3

document.write(&quot;<div><font face=arial color=#000000 size=1 height=25 width=25>your page here</font><br></div>&quot;)


//Including a remote file accross servers- to be used for things like headline sharing etc
// // There are two files here-
// (1)The target file where your are 'including' the file- call it target.html or whatever you want
// (2)The include file - call it index.php3 or to change , change the link on the target.html page

// Known issues-
// -(2)index.php3 must all be on one line in the text editor- if the second line
// is there, even with no characters then there will be a javascript error.
// - you can include a third file into index.php3 say from a database, but remember again this third file would need to be on one line
// So make sure you have text editor which shows line numbers!!
// Javascript doesnt seem to limit the amount of characters it can read on one line so the file your are including can be any length you want Caspar Kennerdale
Senior Media Developer
 
Or you could do this server-side with this simple script:

#!/usr/bin/perl
use LWP::Simple;
$url='$content = get($url);
print &quot;Content-type: text/html\n\n&quot;;
print &quot;$content&quot;;

Much cleaner, IMHO. This script only prints out the content of your file, but you can likewise print out other data on the same page, such as content from another HTML file on this system or another. You could also parse the contents of the file and make changes to it fairly easily. If you want to go this route, there are several experts in the Perl forum who would be happy to help you with any problems you may run into.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
You might want to try the HTTP socket component at Dimac. It's free of charge, and it lets you emulate an HTTP get request. here's the link:


good luck!
 
We wrote a script that helps maintain large volumes of Include Files, we call it csIncludes. All you have to do is add the text, the command is written for you and managed in a list. Check out the demo on our site.

I know, it is a shameless plug, but you asked.

» » » » » »
Mike Barone
FREE and Pro CGI/Perl Scripts

FREE Scripts
 
Thanks alot for your answers!! They helped a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top