Jump to content

FTP problems


Go to solution Solved by JustSomeone,

Recommended Posts

Hello again,

Func _putFiles()
Local $connection = _FTP_Open('MyFTP Control')
If @error Then ConsoleWrite("FTP Open error : " & @error & @CRLF)
Local $Conn = _FTP_Connect($connection, $server, $username, $pass)
If @error Then ConsoleWrite("FTP Connect error : " & @error & @CRLF)
      If $Conn = 0 Then
             MsgBox(0, "Error", "No internet connection, please try again")
             Exit
         Else
             _FTP_DirSetCurrent($connection, $hdir)
            If @error Then ConsoleWrite("FTP Current dir set : " & @error & @CRLF)
            local $Remote_List = _Ftp_ListToArray($connection, 2)
            If @error Then ConsoleWrite("FTP List to array error : " & @error & @CRLF)
            _ArrayDisplay($Remote_List, "something")
            If @error Then ConsoleWrite("Array display error : " & @error & @CRLF)
            _FTP_FilePut($connection, $aFile, $destfile)
            If @error Then ConsoleWrite("FTP File put error : " & @error & @CRLF)
            sleep(100)
        EndIf

Local $Ftpc = _FTP_Close($connection)
If @error Then ConsoleWrite("FTP Close error : " & @error & @CRLF)
EndFunc

Console gives me this

FTP Current dir set : -1
Array display error : 1
FTP File put error : -1
 
No array is displayed and no file is being uploaded. Tried looking around the forum, nothing actually useful for resolving this problem  was found (except the consolewrite with error lines, was using mine version)
 
Any ideas what might be wrong? I am sure i can get connection, because i was having another errorcheck that showed me the wellcome message from the FTP server. I am trying to upload single bin file with the name 1111.22.33.44.55.bin
 
Local $aFile = @TempDir & "\" & $date &".bin "
Local $destfile = $date & ".bin"

The other functions in the program work fine (i.e. file being properly created and such, variables are OK )

 

Note : the FTP server seems to use TLS, but regular connections are OK too

Some output from winscp log

2013-11-26 11:04:17.008 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
< 2013-11-26 11:04:17.008 220-You are user number 5 of 128 allowed.
< 2013-11-26 11:04:17.008 220-Local time is now 12:04. Server port: 21.
< 2013-11-26 11:04:17.008 220-This is a private system - No anonymous login
< 2013-11-26 11:04:17.008 220-IPv6 connections are also welcome on this server.
< 2013-11-26 11:04:17.008 220 You will be disconnected after 5 minutes of inactivity.
> 2013-11-26 11:04:17.008 USER ..
< 2013-11-26 11:04:17.008 331 User .. OK. Password required
> 2013-11-26 11:04:17.008 PASS ***********
< 2013-11-26 11:04:17.008 230 OK. Current restricted directory is /
> 2013-11-26 11:04:17.008 SYST
< 2013-11-26 11:04:17.008 215 UNIX Type: L8
> 2013-11-26 11:04:17.008 FEAT
< 2013-11-26 11:04:17.008 211-Extensions supported:
< 2013-11-26 11:04:17.008  EPRT
< 2013-11-26 11:04:17.008  IDLE
< 2013-11-26 11:04:17.008  MDTM
< 2013-11-26 11:04:17.008  SIZE
< 2013-11-26 11:04:17.008  MFMT
< 2013-11-26 11:04:17.008  REST STREAM
< 2013-11-26 11:04:17.008  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
< 2013-11-26 11:04:17.008  MLSD
< 2013-11-26 11:04:17.008  AUTH TLS
< 2013-11-26 11:04:17.008  PBSZ
< 2013-11-26 11:04:17.008  PROT
< 2013-11-26 11:04:17.008  ESTA
< 2013-11-26 11:04:17.008  PASV
< 2013-11-26 11:04:17.008  EPSV
< 2013-11-26 11:04:17.008  SPSV
< 2013-11-26 11:04:17.008  ESTP
< 2013-11-26 11:04:17.008 211 End.
. 2013-11-26 11:04:17.059 Connected
. 2013-11-26 11:04:17.059 Got reply 1 to the command 1
. 2013-11-26 11:04:17.059 --------------------------------------------------------------------------
. 2013-11-26 11:04:17.059 Using FTP protocol.
. 2013-11-26 11:04:17.059 Doing startup conversation with host.
> 2013-11-26 11:04:17.110 PWD
< 2013-11-26 11:04:17.118 257 "/" is your current location
. 2013-11-26 11:04:17.118 Got reply 1 to the command 16
. 2013-11-26 11:04:17.162 Changing directory to "/".
> 2013-11-26 11:04:17.162 CWD /
< 2013-11-26 11:04:17.170 250 OK. Current directory is /
. 2013-11-26 11:04:17.170 Got reply 1 to the command 16
. 2013-11-26 11:04:17.170 Getting current directory name.
> 2013-11-26 11:04:17.170 PWD
< 2013-11-26 11:04:17.177 257 "/" is your current location
. 2013-11-26 11:04:17.177 Got reply 1 to the command 16
. 2013-11-26 11:04:17.364 Retrieving directory listing...
> 2013-11-26 11:04:17.364 TYPE A
< 2013-11-26 11:04:17.364 200 TYPE is now ASCII
> 2013-11-26 11:04:17.364 PASV
< 2013-11-26 11:04:17.364 227 Entering Passive Mode (91,196,124,127,238,109)
> 2013-11-26 11:04:17.364 MLSD
Link to comment
Share on other sites

Hi JustSomeone.

  It looks to me thatyou are not connecting to the folder of your choice $hDir,  and when that doesnt happen the other 2 fail automatically.

I would try to connect in passive mode for starters:

Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

 

Lots can go wrong with an ftp connect, you might have to change little things and try and try again until you find the culprit.

 

good luck,

Bill
 

Link to comment
Share on other sites

Default dir is the home dir (wich is /) and hdir is the same - local $hdir = "/" 

is this a problem?

Created folder hdir on the FTP, then changed $hdir to "hdir"

same errors

EDIT: changed the file to use xxxx-xx-xx-xx-xx.bin format, still same errors

Edited by JustSomeone
Link to comment
Share on other sites

 

try this:

_FTP_DirSetCurrent($connection, "") ; or "/" you'll have to test it

As i stated before, the home dir was set to / then i tried using "hdir" as directory. I even tried some more solutions (different names, without setcurrentdir and etc) nothing happened, and i still get the errors. I also tried using _FTP_ProgressUpload but it gives me error -3 wich is "Create File failed". 

Tried your suggestion to set the current dir to / and to /hdir  and hdir without them being variables, not successful, same errors

edited something to make things more clear

Edit2 : added some more lines to the console write, and added another getdir

result : 

Array display error  : 1
FTP Get dir before setdir error : -1
Current directory before setdir : 0
FTP Set dir error : -1
FTP Get dir after setdir error : -1
Current directory after setdir : 0
FTP File put error : -3
Edited by JustSomeone
Link to comment
Share on other sites

I'm at work so I cant test any of this and its mostly from memeory...

try running your code without this line

             _FTP_DirSetCurrent($connection, $hdir)
            If @error Then ConsoleWrite("FTP Current dir set : " & @error & @CRLF)
 

if you are connecting wout problems and you cant change or set dir its normally either a syntax or permissions problem with the hookup.

Start with simplest connect that works and add things 1 at a time next step after connect would down or upload regardless of the dir.

then go from there.

cya

Bill

Link to comment
Share on other sites

  • Solution

Something i deleted here

I'm complete retard, i had it wrong way

If @error Then ConsoleWrite("FTP Open error : " & @error & @CRLF)
Local $Conn = _FTP_Connect($connection, $server, $username, $pass)
If @error Then ConsoleWrite("FTP Connect error : " & @error & @CRLF)
      If $Conn = 0 Then
             MsgBox(0, "Error", "No internet connection, please try again")
             Exit
         Else
             _FTP_DirSetCurrent($connection, $hdir)

this should use $Conn instead of $connection

If @error Then ConsoleWrite("FTP Open error : " & @error & @CRLF)
Local $Conn = _FTP_Connect($connection, $server, $username, $pass)
If @error Then ConsoleWrite("FTP Connect error : " & @error & @CRLF)
      If $Conn = 0 Then
             MsgBox(0, "Error", "No internet connection, please try again")
             Exit
         Else
             _FTP_DirSetCurrent($Conn, $hdir)

script continue here -------------^ here is the problem
Edited by JustSomeone
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...