home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
perl_ste.zip
/
auto
/
Net
/
FTP
/
login.al
< prev
next >
Wrap
Text File
|
1997-11-28
|
1KB
|
61 lines
# NOTE: Derived from ./blib/lib/Net/FTP.pm. Changes made here will be lost.
package Net::FTP;
sub login
{
my($ftp,$user,$pass,$acct) = @_;
my($ok,$ruser);
unless (defined $user)
{
require Net::Netrc;
my $rc = Net::Netrc->lookup(${*$ftp}{'net_ftp_host'});
($user,$pass,$acct) = $rc->lpa()
if ($rc);
}
$user ||= "anonymous";
$ruser = $user;
if(defined ${*$ftp}{'net_ftp_firewall'})
{
$user .= "@" . ${*$ftp}{'net_ftp_host'};
}
$ok = $ftp->_USER($user);
# Some dumb firewalls don't prefix the connection messages
$ok = $ftp->response()
if($ok == CMD_OK && $ftp->code == 220 && $user =~ /\@/);
if ($ok == CMD_MORE)
{
unless(defined $pass)
{
require Net::Netrc;
my $rc = Net::Netrc->lookup(${*$ftp}{'net_ftp_host'}, $ruser);
($ruser,$pass,$acct) = $rc->lpa()
if ($rc);
$pass = "-" . (getpwuid($>))[0] . "@"
if (!defined $pass && (!defined($ruser) || $ruser =~ /^anonymous/o));
}
$ok = $ftp->_PASS($pass || "");
}
$ok = $ftp->_ACCT($acct || "")
if ($ok == CMD_MORE);
$ftp->authorize()
if($ok == CMD_OK && defined ${*$ftp}{'net_ftp_firewall'});
$ok == CMD_OK;
}
1;