Is it possible to open a file at a second ISP?

J

Jerry

When running a script at the first ISP I want to open a file at a
mirror site on a second ISP and append to it. Is this possible?

I know this does not work.

open(FILE,">>/www/user/mysite2.com/WORLD_WRITABLE/notification.sav") ||
die "cannot open notification.sav: $!";
foreach my $p (param()) {
print FILE "$p = ", param($p), "\|";
} print FILE "\n";

close (FILE);

I was told at another forum that I will have to write a program using
the http call to do this. I am far from a Perl programmer, but have
researched my 11 books (including 6 O'Reilly Books and the Stein cgi.pm
book) and the PerlFaqs and found nothing on this.
 
M

Matt Garrish

Jerry said:
When running a script at the first ISP I want to open a file at a
mirror site on a second ISP and append to it. Is this possible?

I know this does not work.

open(FILE,">>/www/user/mysite2.com/WORLD_WRITABLE/notification.sav") ||
die "cannot open notification.sav: $!";
foreach my $p (param()) {
print FILE "$p = ", param($p), "\|";
} print FILE "\n";

close (FILE);

I was told at another forum that I will have to write a program using
the http call to do this. I am far from a Perl programmer, but have
researched my 11 books (including 6 O'Reilly Books and the Stein cgi.pm
book) and the PerlFaqs and found nothing on this.

I suspect your advice was to write a separate cgi script (or web service) on
the second machine and then post the data from the script on the first
machine. For a cgi, see the LWP documentation (including lwpcook) for how to
post data to another server. I'll assume that you can write a script to
process the call and write the data to the file once it gets there. You
might also want to have a look at the SOAP::* modules, but I would have to
think a cgi is simpler in this case.

Matt
 
U

usenet

Jerry said:
When running a script at the first ISP I want to open a file at a
mirror site on a second ISP and append to it. Is this possible?

open(FILE,">>/www/user/mysite2.com/WORLD_WRITABLE/notification.sav") ||

That command will look for a file in a local filesystem called
/www/user....

You can use File::Remote to open a remote file "as if" it were a local
file, or you can transfer an existing file with something like Net::FTP
or NET::SFTP.
 
G

Gunnar Hjalmarsson

Jerry said:
When running a script at the first ISP I want to open a file at a
mirror site on a second ISP and append to it. Is this possible?

I was told at another forum that I will have to write a program using
the http call to do this.

Using LWP at the first ISP it's possible. But please be careful, and use
some kind of authentication.
I am far from a Perl programmer, but have
researched my 11 books (including 6 O'Reilly Books and the Stein cgi.pm
book) and the PerlFaqs

Wow, that ought to be more than enough.
 
J

Jerry

Thanks. I went to Nathan Wiger's site and read the doc on
File::Remote. It looks like the answer, but what type of address is
supposed to be used for host? What if I had an address of
http://www.mysite.com, would this be the host?
Example:

use File::Remote qw:)replace); # special :replace tag

# read from a remote file
open(REMOTE, "host:/remote/file") or die $!;
print while (<REMOTE>);
close(REMOTE);
 
U

usenet

Jerry said:
Thanks. I went to Nathan Wiger's site and read the doc on
File::Remote. It looks like the answer, but what type of address is
supposed to be used for host? What if I had an address of
http://www.mysite.com, would this be the host?

Try it and see ;)

If it doesn't work, check the error message.
 
G

Gunnar Hjalmarsson

That command will look for a file in a local filesystem called
/www/user....

You can use File::Remote to open a remote file "as if" it were a local
file,

Had never heard of File::Remote, but it sounds kind of strange to me.
The docs say: "It allows you to create and edit files without having to
worry about their physical location on the network." But two ISPs aren't
likely on the same network, or...?
 
D

Dr.Ruud

Gunnar Hjalmarsson:
Had never heard of File::Remote, but it sounds kind of strange to me.
The docs say: "It allows you to create and edit files without having
to worry about their physical location on the network." But two ISPs
aren't likely on the same network, or...?

I haven't checked, but it could use scp, or even (s)ftp, to cache and
edit local copies, and update the remote originals (internet as "the
network").
 
G

Gunnar Hjalmarsson

Dr.Ruud said:
Gunnar Hjalmarsson:

I haven't checked, but it could use scp, or even (s)ftp, to cache and
edit local copies, and update the remote originals (internet as "the
network").

Yeah, but since the POD examples don't include login stuff, I began to
wonder.
 
D

Dr.Ruud

Gunnar Hjalmarsson:
Dr.Ruud:

Yeah, but since the POD examples don't include login stuff, I began to
wonder.

OK, now I have checked
http://search.cpan.org/~nwiger/File-Remote/Remote.pm
and in the Description it says:
"If a file passed into a function is of the form host:/path/to/file,
then File::Remote uses rsh/rcp (or ssh/scp, depending on how you
configure it) to edit the file remotely. [...] One advantage of the
object-oriented method is that this allows you to read and write from
different servers using different methods (eg, rsh vs. ssh)
simultaneously"
From the Notes: "the remote file is not synched until close() is called
on the filehandle."
 

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,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top