Page 1 of 3
HMG FTP Sample ?
Posted: Sat Jun 20, 2020 1:48 am
by AUGE_OHR
hi,
i´m looking for a FTP Sample
under HMG i just found some "small" Sample for FTP up/download.
dnldftp.prg ftpadv.prg tipwget.prg upld_ftp.prg
---
found in Extendet Version ( 2020/05 2nd Update)
c:\MiniGUI\SAMPLES\Advanced\FtpClient\
it does build without Error but when run i got this Error
Application: C:\MiniGUI\SAMPLES\Advanced\FtpClient\demo.exe
Time from start: 0 days 0 hours 0 mins 0 secs
Error BASE/1073 Argument error:
--------------------------------- Stack Trace ---------------------------------
Called from (b)_ADDGRIDROW(507) in module: h_grid.prg
Called from AEVAL(0)
Called from _ADDGRIDROW(507) in module: h_grid.prg
Called from (b)INITDIALOGGRID(418) in module: h_grid.prg
Called from AEVAL(0)
Called from INITDIALOGGRID(418) in module: h_grid.prg
Called from _DEFINEGRID(357) in module: h_grid.prg
Called from MAIN(23) in module: demo.prg
who can help me please
Re: HMG FTP Sample ?
Posted: Sat Jun 20, 2020 8:08 am
by serge_girard
Jimmy,
Here small working sample:
Code: Select all
oUrl := tUrl():New()
oUrl:cProto := 'ftp'
oUrl:cServer := cServer
oUrl:cPath := '' // cRemotePath
oUrl:cFile := '' // cRemoteFileName
oUrl:cUserid := cUserName
oUrl:cPassword := cPassword
oFtp := tIPClientFtp():New( oUrl )
CC := 0
DO WHILE .T.
IF oFtp:open()
EXIT
ELSE
CC++
IF CC >= 4
? "Retry to connect again to FTP server? " + STRVALUE( oFtp:lastErrorMessage())
RETURN .F.
ELSE
IF 'TIMEOUT' == ALLTRIM(UPPER(oFtp:lastErrorMessage()))
//oFtp:nConnTimeout := oFtp:nConnTimeout + 10000 // +1000
ENDIF
ENDIF
ENDIF
ENDDO
IF .NOT. oFtp:open()
? oFtp:lastErrorMessage()
RETURN
ENDIF
oFtp:cwd( "/domains/.......com/public_html/" )
? oFtp:cReply
? oFtp:lastErrorMessage())
aFILES_WWW := oFtp:listFiles() // on serverside
? oFtp:lastErrorMessage())
aFILES_WWW := ASORT(aFILES_WWW,,, { |x, y | x [F_NAME] < y [F_NAME] } )
aFILES_WWW2 := {}
IF LEN(aFILES_WWW) == 0
? 'listFiles == 0 '
RETURN
ENDIF
? LEN(aFILES_WWW)
FOR x := 1 TO LEN(aFILES_WWW)
IF aFILES_WWW[ x, F_NAME] == "." .OR. aFILES_WWW[ x, F_NAME ] == ".." .OR. UPPER(SUBSTR(aFILES_WWW[x, F_ATTR],1,1)) == 'D'
ELSE
IF '.PHP' $ UPPER(aFILES_WWW[ x, F_NAME] )
IF 'PAR' $ UPPER(aFILES_WWW [X , F_NAME] ) .OR. 'NAK' $ UPPER(aFILES_WWW [X , F_NAME] )
// delete on server side !!!!!
oFtp:Dele(aFILES_WWW [X , F_NAME])
ENDIF
ENDIF
ENDIF
NEXT
oFtp:close()
/* upload * /
RmtFileM := "/domains/.....com/public_html/" + LOWER(cFILENAME)
LclFileM := cPATH + cFILENAME
IF .NOT. oFtp:uploadFile(LclFileM, RmtFileM)
? ' NOK ' + LclFileM + STRVALUE( RmtFileM) + STRVALUE(oFtp:cReply) + STRVALUE(oFtp:lastErrorMessage())
ELSE
? 'UPDATE: ' + STRVALUE( cFILENAME) + STRVALUE(RmtFileM) + ' ' + STRVALUE( LclFileM)
ENDIF
*/
Serge
Re: HMG FTP Sample ?
Posted: Sat Jun 20, 2020 9:18 pm
by AUGE_OHR
hi Serge,
thx for your Code
---
i got c:\MiniGUI\SAMPLES\Advanced\FtpClient\demo.prg running
but "Result" is not like DIRECTORY ...
---
in your Code i saw
Code: Select all
aFILES_WWW := oFtp:listFiles() // on serverside
so i try this
Code: Select all
function ftpConnect()
LOCAL bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )
LOCAL lConnect := .F.
...
oClient := TIpClientFtp():new( oUrl )
oClient:nConnTimeout := 2000
oClient:bUsePasv := .T.
BEGIN SEQUENCE
// here Extendet Version hang without BREAK ?!
IF oClient:Open()
lConnect := .T.
ELSE
lConnect := .F.
MsgInfo("Connection is not opened", "Alert")
ENDIF
RECOVER
ERRORBLOCK( bError )
MsgInfo("Connection FAIL", "Alert")
END SEQUENCE
ERRORBLOCK( bError )
IF lConnect = .T.
...
acDir := oClient:listFiles() // on serverside
but when look at acDir it have 8 Element ...

- ListFiles_1.JPG (85.34 KiB) Viewed 3756 times

- ListFiles_2.JPG (73.46 KiB) Viewed 3756 times
what to do with it ...
---
i found c:\harbour\contrib\hbtip\ftpcli.prg
it is from harbour "core-master" ZIP
Code: Select all
CREATE CLASS TIPClientFTP INHERIT TIPClient
METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClientFTP
METHOD Open( cUrl ) CLASS TIPClientFTP
METHOD Close() CLASS TIPClientFTP
METHOD GetReply() CLASS TIPClientFTP
METHOD Commit() CLASS TIPClientFTP
METHOD ScanLength() CLASS TIPClientFTP
METHOD TransferStart() CLASS TIPClientFTP
METHOD Pasv() CLASS TIPClientFTP
METHOD Quit() CLASS TIPClientFTP
METHOD TypeI() CLASS TIPClientFTP
METHOD TypeA() CLASS TIPClientFTP
METHOD NoOp() CLASS TIPClientFTP
METHOD Rest( nPos ) CLASS TIPClientFTP
METHOD PWD() CLASS TIPClientFTP
METHOD CWD( cPath ) CLASS TIPClientFTP
METHOD Dele( cPath ) CLASS TIPClientFTP
METHOD LS( cSpec ) CLASS TIPClientFTP
METHOD Rename( cFrom, cTo ) CLASS TIPClientFTP
METHOD MKD( cPath ) CLASS TIPClientFTP
METHOD RMD( cPath ) CLASS TIPClientFTP
METHOD Retr( cFile ) CLASS TIPClientFTP
METHOD Stor( cFile ) CLASS TIPClientFTP
METHOD List( cSpec ) CLASS TIPClientFTP
METHOD UserCommand( cCommand, lPasv, lReadPort, lGetReply ) CLASS TIPClientFTP
METHOD Port() CLASS TIPClientFTP
METHOD SendPort() CLASS TIPClientFTP
METHOD ReadAuxPort() CLASS TIPClientFTP
METHOD Read( nLen ) CLASS TIPClientFTP
METHOD Write( cData, nLen ) CLASS TIPClientFTP
METHOD MGet( cSpec, cLocalPath ) CLASS TIPClientFTP
METHOD MPut( cFileSpec, cAttr ) CLASS TIPClientFTP
METHOD UploadFile( cLocalFile, cRemoteFile ) CLASS TIPClientFTP
METHOD DownloadFile( cLocalFile, cRemoteFile ) CLASS TIPClientFTP
METHOD FileSize( cFileSpec ) CLASS TIPClientFTP
METHOD ListFiles( cFileSpec ) CLASS TIPClientFTP
are there any Description what those Method doing

Re: HMG FTP Sample ?
Posted: Sat Jun 20, 2020 10:52 pm
by danielmaximiliano
Re: HMG FTP Sample ?
Posted: Sun Jun 21, 2020 12:53 am
by AUGE_OHR
hi,
thx for Answer.
Online Help of FTPclient does not show any Sample ...
i got HMG Version so far that i begin with download
in this Sample many files show Error 550 but some files ARE download ... ZIP, PDF and MKV while other fail

- FTP_Not_Found.JPG (123.3 KiB) Viewed 3739 times
here Party_2.MKV fail while DevConParty_1.MKV was download.
btw. there is no Progressbar while download
---
i do have a modify HMG32.HBC while using hbTIP with SSL ...
Code: Select all
# ***** include this lines *****
libs=hbssl
libs=libeay32
libs=ssleay32
Libs=hbtip
# ***** end include this lines *****
can it make Problem with FTPclient()

Re: HMG FTP Sample ?
Posted: Sun Jun 21, 2020 2:04 am
by danielmaximiliano
Jimmy : 500 Series Syntax error, command unrecognized and the requested action did not take place. This may include errors such as command line too long.
If the FTP site accepts your connection, the HBTIP library works correctly.
you must list all the content of the site and save it for future FTP operations, you must determine the time for an operation to be successful, use an error control that allows you to continue with the next ftp operation, the failed operations must remain pending after reporting the detail by means of a LOG.
Re: HMG FTP Sample ?
Posted: Sun Jun 21, 2020 2:53 am
by danielmaximiliano
try using commands through the FTP included in windows to check the files that give error

- 2020-06-20 23_24_01-Window.png (45.53 KiB) Viewed 3724 times

- 2020-06-20 23_47_37-Window.png (20.19 KiB) Viewed 3724 times
Re: HMG FTP Sample ?
Posted: Sun Jun 21, 2020 5:39 am
by AUGE_OHR
hi,
i have made a Sample for HMG.
it include all Source (from Extended Version) to run it under HMG Environment
latest Version does not use *.FMG -> now STATIC PROC
Files list in right-GRID are from
Code: Select all
acDir := oClient:listFiles() // on serverside
so "path" are same and files does exist and i can download ALL with "other FTP" App
but i only can download 2nd File "DevConParty_1.MKV" with my HMG App ... hm
as i say i got 8 x Element using oClient:listFiles() which are not same like Directory() ( F_* Constant)
---
the Original Source show 2007 in Title ... is it still valid

Re: HMG FTP Sample ?
Posted: Sun Jun 21, 2020 1:16 pm
by danielmaximiliano
Hi Jimmy :
1) Missing hbwapi.h
2) the first time does not save the site, entering it the second time gives an error when trying to connect
3) it bothers that the app is always in the foreground

- 2020-06-21 10_22_47-FTP Client -2020- Original by - Walter Formigoni - OPEN SOURCE. Version 0.0.5.png (44.19 KiB) Viewed 3674 times
HBtip suffers from always connecting from a command line
oClient: Open ()
That way you never know if the URL, username or password is wrong.
Code: Select all
IF AT( "@", cUser ) > 0
oClient:oUrl:cServer := cServer
oClient:oUrl:cUserID := cUser
oClient:oUrl:cPassword := cPassword
ENDIF
BEGIN SEQUENCE
IF oClient:Open()
lConnect := .T.
ELSE
lConnect := .F.
MsgInfo( "Connection is not opened", "Alert" )
ENDIF
RECOVER
ERRORBLOCK( bError )
MsgInfo( "Connection FAIL", "Alert" )
END SEQUENCE
ERRORBLOCK( bError )
IF lConnect = .T.
IF EMPTY( oClient:cReply )
oClient:Pasv()
ELSE
oClient:Pasv()
ENDIF
Re: HMG FTP Sample ?
Posted: Sun Jun 21, 2020 1:45 pm
by danielmaximiliano
This test service is active for tests and this is the current content for 30 minutes. The files that are uploaded for tests of uploads and downloads are available.

- 2020-06-21 10_44_29-Window.png (21.65 KiB) Viewed 3673 times