Jump to content

FTP <FTPEx.au3>


Recommended Posts

Hi , 

    I feel like a newbie this friday afternoon.

Basically iam trying to connect a ftp enter a folder , go back up and enter a new one.

I did never found out how to do the up one level . or just back to root will do for my script i did try all the combo i know for that like

_FTP_Command($Conn,"cwd ..")

_FTP_Command($Conn,"cwd ::")

_FTP_Command($Conn,"cwd ../")

_FTP_Command($Conn,"cwd /")

So being lazy on this friday , i just did 2 full connection process in 2 function . to my big surprise still stuck with file list from my first  function into my second.

So i did rename all my variable to new name in 2 function , still the same problem .

I guess some call do not get clean close . from bug to typo any one got a idea where i screw up .

Here a ugly coding test , but i just cannot get those 2 function work back to back , individually they work perfect .

Obvious i can do ftp via batch/PS/vbs , but i rather have this work in 1 pass 

Anyone got a idea what wrong here ?

#include <FTPEx.au3>
#include <Array.au3>

ftpgetfile()
sleep(1000)
ftpgetfile2()

Func ftpgetfile()

Local $server = 'ftp.test.local'
Local $username = 'myuser'
Local $pass = 'mypass'
Local $Open = _FTP_Open('MyFTP Control')
Local $Conn = _FTP_Connect($Open, $server, $username, $pass,1)

_FTP_Command($Conn,"cwd /folder1")
Local $IDS_File = _FTP_ListToArrayEx($Conn, 0)
;_ArrayDisplay($IDS_File)
$IDS_SIZE = UBound($IDS_File)
$IDS_LASTFILE = $IDS_File[$IDS_SIZE -1 ][0]
;MsgBox(1,"tt",$IDS_LASTFILE)
_FTP_FileGet($Conn, $IDS_LASTFILE,@ScriptDir & "\data\" & 'IDS_' & $IDS_LASTFILE)
Local $Ftpc = _FTP_Close($Open)
EndFunc


Func ftpgetfile2()
Local $server = 'ftp.test.local'
Local $username = 'myuser'
Local $pass = 'mypass'
Local $Open2 = _FTP_Open('MyFTP Control')
Local $Conn2 = _FTP_Connect($Open2, $server2, $username2, $pass2,1)

_FTP_Command($Conn2,"cwd /folder2")
Local $COU_File = _FTP_ListToArrayEx($Conn2, 0)
_ArrayDisplay($COU_File)
$COU_SIZE = UBound($COU_File)
$COU_LASTFILE = $COU_File[$COU_SIZE -1 ][0]
;MsgBox(1,"tt",$COU_LASTFILE)

_FTP_FileGet($Conn2, $COU_LASTFILE,@ScriptDir & "\data\" & 'COU_' & $COU_LASTFILE)
Local $Ftpc = _FTP_Close($Open2)
EndFunc
Link to comment
Share on other sites

  • 1 month later...

Hi Vaner,

try in your second function ftpgetfile2

"Local $server2" instead of "Local $server",

"Local $username2" instead of "Local $username" and

"Local $pass2" instead of "Local $pass".

This will init the second ftp with the desired different credentials and should lead to another file list.

So far i don't found anything else to be wrong.

Edited by Dschingis
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

×
×
  • Create New...