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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Communication 1

Status
Not open for further replies.

sleuth

Programmer
Jan 12, 2001
134
US

Hey Everyone,

I'm trying to send a file from one script on one server to another script on another server, and I've got a question.

Question is, what's the best way to do this, using sockets? Or would Net::FTP be better? I just need to overwrite the file with a file on the local hard drive, it's really like a syncronizing script but very simple. I'm using sockets to download the file, then I write the file to the local hard drive and make the appropriate changes and then I just have to send the file back to my server where it came from, overwriting the origional one.

Thanks Mates,
Tony
 
Net::FTP has *got* to be the way to go. Using sockets for this kind of thing is way too much like hard work - and for something that Net::FTP does perfectly.

I'm impressed that you got the sockets thing to work though :) Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Hehe, Hi Mike,

Thanks For the advice, I'm glad Net::FTP seems to be easy to use and quite stable, I'll be using it on a windows plat also, I saw on cpan that it works fine on windows too.

The socket code was pretty easy, no thanks to the documentation, I remember getting it off a parsing script.


use IO::Socket;
$method = "GET";
$host = " $path = "";
$socket = new IO::Socket::INET( PeerAddr => $host,
PeerPort => 80,
Proto => 'tcp',
Type => SOCK_STREAM, ) or print "$!";
print $socket "$method $path HTTP/1.0\nReferer: $host\n";
print $socket "User-Agent: $ENV{'HTTP_USER_AGENT'}\n\n";
@output = <$socket>;
close ($socket);


A lot of times I wrap this into a sub and pass urls to get really quick, it's handy.

Thanks,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top