Sign in to follow this  
Followers 0
z3r0c00l12

_FTP_FileGet Error

2 posts in this topic

I need help fixing a problem in my script. Running the script below will get me an error -1 sometimes and work flawlessly other times, I just don't know why it isn't consistent. The file on the server is always there and I have permission to write to "C:\". If I check the logs on the FTP server, I'd get :

User logged in.
User Disconnected. (00:00:00)

I'm trying to identify what the error "-1" means for _FTP_FileGet. I've looked through the help file but didn't find anything and I searched MSDN, but couldn't find anything helpful.

Thanks.

#include <FTPEx.au3>
$username="username"
$password="password"
$Open = _FTP_Open("myftp")
If $Open <> 0 Then
    $Conn = _FTP_Connect($Open, "127.0.0.1", $username, $password)
    If $Conn <> 0 Then
        If _FTP_FileGet($Conn,"File.txt","C:\File.txt") <> 1 Then ConsoleWrite("_FTP_FileGet Error: " & @ERROR & @CRLF)
    EndIf
    _FTP_Close($Open)
EndIf

Share this post


Link to post
Share on other sites



BUMP

Here's a little update on this problem. I went looking in the FTPEx.au3 UDF and found it was using SetError on the return function, so I add the @Extended macro to the output, by doing so:

ConsoleWrite("_FTP_FileGet Error: " & @ERROR & " Extended: " & @EXTENDED & @CRLF)

The output of this is now Error: -1 and Extended: 12002.

Google says the error means "The request has timed out."

Is there a way I can make this work more efficiently to prevent this error from happening?

I even added "If Ping("127.0.0.1") > 0 Then" before the ftp connection and the script is able to ping before making the connection. If I connect using Windows Explorer and perform the same operation as the script manually, everything works fine.

Note: The FTP server is not local.

#include <FTPEx.au3>
$username="username"
$password="password"
$Open = _FTP_Open("myftp")
If $Open <> 0 AND Ping("127.0.0.1") > 0 Then
    $Conn = _FTP_Connect($Open, "127.0.0.1", $username, $password)
    If $Conn <> 0 Then
        If _FTP_FileGet($Conn,"File.txt","C:\File.txt") <> 1 Then ConsoleWrite("_FTP_FileGet Error: " & @ERROR & " Extended: " & @EXTENDED & @CRLF)
    EndIf
    _FTP_Close($Open)
EndIf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0