Perl脚本学习经验(三)--Perl中ftp的使用

时间:2022-12-29 16:39:33

使用use Net::FTP;
Demo:
    my $Server = '192.168.1.1';
    my $User = 'admin';
    my $Password = 'admin';
   
    my $ftp = Net::FTP->new($Server,Passive => 0, Debug => 1,Timeout => 10) or die "Could not connect.\n";
    if (defined $ftp)
    {
        if ($ftp->login($User, $Password) or die "Could not login. \n")
        {  
            $ftp->cwd("config");                   #切换目录   
  
            $ftp->put($g_file);                     #上传文件
        }
    }
    $ftp->quit();                                      #退出ftp