I'm trying to write a Perl script where a file from a UNIX server box connects to a Windows server box and copies that file into the Window box.
The main problem I have right now is that whenever I try to connect to the Windows box, the connection is refused.
The error message that always pops up is:
cannot connect to host name: Net::FTP: connect: Connection refused at transfer.pl line 16.
My code is essentially this:
#!/user/bin/perl -w
use strict;
use Net::FTP;
my $directory = `pwd`;
chomp($directory);
$directory .= "/";
#print "Give name of file being transferred:\n";
#chomp($directory .= <>);
my $host = '<server name or ip address>';
my $ftp = Net::FTP->new($host, Debug => 0) or die "cannot connect to host name: $@";
$ftp->quit;
Any thoughts as to why this would happen (ex. firewall issues)?
For the host name, I use the domain name (both the short and full versions) and the actual IP address, but all of them have the same error message.
Many thanks!
First choose a protocol, ssh2 (scp2) is a great first choice, but you seem to be using ftp. There is the mount flavored family like NFS and SAMBA, file only tools like ftp, and file/command tools like rcp/rsh, scp/ssh/sftp, ssh2/scp2/sftp2. There are services, like http, you could create to facilitate this. There are often perl extensions to allow you to do these inside perl.
Get the protocol working from the command line before getting into code with it.