Using File::Copy and Sockets to copy public files from http addresses
My company has a relationship with a partner where they post files on
their website for us to download. I am writing a perl script to
automate the process.
I begin by using the File::Copy module to provide the basic Copy
function. However, since the souce file is not in my Host's
directory, I believe I need to set up a Socket to provide connectivity
to the partner server where the file lives and that is where I need
help.
The code fragment I am working with is as follows but it does not work
for me. I would appreciate some help.
use Socket;
$domain = PF_INET;
$type = SOCK_STREAM;
$proto = getprotobyname('tcp');
socket(PARTNER, $domain, $type, $proto) or die "socket: $!\n";
$port = 0;
$sockaddr = sockaddr_in($port, INADDR_ANY);
bind(PARTNER, $sockaddr) or die "bind: $!\n";
$host = ' http://www.*-*-*.com/ $ProductID.txt';
$port = getservbyname('http', 'tcp');
$ip_addr = inet_aton($host) or die "inet_aton: $!\n";
$sockaddr = sockaddr_in($port, $ip_addr);
connect(PARTNER, $sockaddr) or die "connect: $!\n";
use File::Copy;
copy PARTNER, "../www/mono_mp3/$ProductID.mp3";
Thanks for you time and help,
Jeff