Forum Moderators: coopster & phranque

Message Too Old, No Replies

Copy files from another server

         

Snookered

6:45 am on Feb 16, 2004 (gmt 0)

10+ Year Member



Hi,

I'm trying to get a script working that allows me to copy html files that I create on one server, to another server. I've searched on here and found a previous subject about it but it was not really what I needed.

In addition I can't get the following to work:

use File::Copy;
copy("http://wwww.myotherfile.com/topic3.html", "new_file.html");

The following creates the new_file.html but it is blank inside:

#!/usr/local/bin/perl

open(FILEREAD, "< [wmyotherfile.com...]
open(FILEWRITE, "> newfile****.txt");
while (<FILEREAD>){
print FILEWRITE;
}
close FILEWRITE;
close FILEREAD;

I've set chmod to 755 in each case.

Does anybody know what I need to do to copy one file from another server?

Thanks.

Laxters

12:09 am on Feb 19, 2004 (gmt 0)

10+ Year Member



You'll probably need an FTP login to read/write files from one server to another. Try looking up perl FTP commands and set it up that way.

JasonD

1:12 pm on Feb 19, 2004 (gmt 0)

10+ Year Member



Try LWP::Simple


use LWP::Simple;
my $file = get('http://wwww.myotherfile.com/topic3.html');

Should make life a lot easier for you :)

Snookered

8:11 pm on Feb 23, 2004 (gmt 0)

10+ Year Member



Thanks, I've found that I needed to extend the destination path so: copy("http://wwww.myotherfile.com/topic3.html", "public_html/new_file.html");

Rather than just "new_file.html".