sreegouthamreddy has asked for the wisdom of the Perl Monks concerning the following question:

I am using a perl script to Connect to an FTP Server in my network from where i ahve to downlaod the files. But the Login Module is throwing an error as below "Invalid sequence of commands (AUTH SSL/TLS required prior to authentication)" Below is the Code Snippet

use Net::FTP; $strFTPServer = <<sever>>; $strFTPUserName = <<username>>; $strFTPPassword = <<Password>>; newFTPConn(); sub newFTPConn() { $ftp = Net::FTP->new("$strFTPServer", Passive => 0, Debug => 0) || + retryModule("Could not connect to FTP Server $strFTPServer: $!"); $logger->info("Successfully connected to FTP Server $strFTPServer" +); $ftp->login("$strFTPUserName","$strFTPPassword") || errorModule("U +serName or Password incorrect for user $strFTPUserName: ".$ftp->messa +ge,1); $logger->info("Successfully logged into $strFTPServer"); }

Replies are listed 'Best First'.
Re: AUTH SSL/TLS required prior to authentication
by noxxi (Pilgrim) on Jan 16, 2016 at 22:04 UTC

    The server means that you are not allowed to authorize on the plain connection but that you need to first upgrade the connection to TLS using the AUTH TLS command.

    Starting with Version 3.0 Net::FTP has TLS included if you have a recent version of IO::Socket::SSL installed. In this case you need to just add a starttls call before you login:

    use Net::FTP 3.01; $ftp = Net::FTP->new(...) or die; $ftp->starttls or die; $ftp->login(...);
Re: AUTH SSL/TLS required prior to authentication
by 1nickt (Canon) on Jan 16, 2016 at 01:15 UTC

    Not related to your question, but there's no need to use parentheses on your sub declaration: you're just telling Perl that no arguments are allowed, and by placing the call before the sub Perl can't check what the sub allows anyway.

    If you had use warnings; Perl would have told you this:

    $ perl -wE' foo("bar"); sub foo() { 1; } ' main::foo() called too early to check prototype at -e line 2.
    $ perl -wE' sub foo() { 1; } foo("bar"); ' Too many arguments for main::foo at -e line 3, near ""bar")" Execution of -e aborted due to compilation errors.

    The way forward always starts with a minimal test.