I'm having a problem with NET::FTP.  Please see code below. My problem seems to
be with the login method call, the error I get is: Can't call method "login" on
an undefined value at putcffile.pl line 56.

I know this is not a FW issue because I'm testing by ftp'ing to myself and I can
login in with the credenials I'm using from the cmd line. OS is W2k. Could
problem have something to do with salar referencing or quoting within NET::FTP?
What about using IP # for host value, is that exceptable?  Using debug, socket
seems to be established okay from the call to "Net::FTP->new".   Also, is the
method below correct to ensure binary transmisson?  

TIA,
Harold Cook   

#----Begin----
use strict;
use Net::FTP;
use Getopt::Long;
     
my $opt_debug = 10;
my $opt_firewall = undef;
     
GetOptions(qw(debug firewall=s));
     
my @firewall = defined $opt_firewall ? (Firewall => $opt_firewall) : ();

my $some_dir='c:\\location\\files'; 

my $host='xxx.xx.50.51';

my $user='username';

my $pass='passwordxx';

# Start process to select file
(chdir 'C:/location/files') || die "Can't cd to CacheFlows\BSM directory: $!\n";
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
my @files100 = grep { /CF_100_/ && -f "$some_dir/$_" } readdir(DIR);
closedir DIR;

open(TXT100,">file100.txt") || die "can't open txt";
#print TXT100 "[EMAIL PROTECTED]";
sort @files100[$#files100];
my $file100 = @files100[$#files100];
print TXT100 "$file100\n" ; 
close TXT100;
###call ftp sub here
my $file=$file100;
ftpit($host, $user, $pass, $file);


# End select file process 
#=====


sub ftpit
{
print "$_[0]: $_[1]\n";
print "$_[2]: $_[3]\n";

    
my ($host, $user, $pass, $file) = @_;
my $wkdir='/u02/';

print 'username= ', $user, ' logging in on host= ', $host, ' password=xxxxxxxx',
"\n"; 
print 'sending file: ', $file, "\n"; 

my $ftp = Net::FTP->new($host, @firewall, Debug => $opt_debug ? 1 : 0); 
my $ftp->login("$user", "$pass") or die "can't login to ftp server",
$ftp->message;
my $ftp->cwd($wkdir);
my $ftp->binary();
my $ftp->put($file, $file);
my $ftp->quit;
return 1;
}     
#----end----
     
     

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to