Hi,
Please check out the following code:
If you take a look at the aMatch array in the url.prg shipped with Harbour, the user and the password are not correctly detected because of ‘@’ in the username and ‘:’ or ‘@’ within the password. The username in the given context is assigned by the FTP Admins and cannot be changed. So how to overcome the problem ? As of now, no FTP log is generated to analyze the problem.
Just for information, use of any other FTP Clients viz. CoreFTP,FileZilla works correctly.
/* code begins */
STATIC FUNCTION ftpDB(aFiles)
LOCAL cStartTime := Time(), cEndTime :=""
LOCAL cServer := "ftp.abc.com" , cUser := "j...@ujayadev.com", cPassword := "Table@chair3"
LOCAL lRetVal := .F.
LOCAL cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer
LOCAL oUrl := TUrl():New( cUrl )
LOCAL oFTP := TIPClientFTP():New(oUrl , .t. ) //TIPClientFTP():New( oUrl, .F. )
LOCAL i := 0
oFTP:nConnTimeout := 20000
oFTP:bUsePasv := .T.
IF oFTP:Open(cUrl) /* fails here */
if oFtp:Cwd( "/ugrani/" )
logdebug("Directory changed to ugrani"+oURL:cServer+hb_eol())
else
ErrorLevel( iif( lRetVal, 0, 1 ) )
logdebug("Directory could not be changed to ugrani,exiting"+oURL:cServer+hb_eol())
RETURN .F.
endif
/* fetch files to transfer */
IF ! Empty( aFiles )
FOR i = 1 to Len(aFiles)
logdebug("Filename: "+aFiles[ i ]+hb_eol())
IF ! oFtp:UploadFile( aFiles[ i ] )
lRetVal := .F.
EXIT
ENDIF
NEXT
oFTP:Close()
endif
ELSE
logdebug("Could not connect to FTP server "+oURL:cServer+hb_eol())
logdebug("Error: ",oFTP:LasterrorCode(),oFTP:Lasterrormessage())
IF oFTP:SocketCon == NIL
logdebug("Connection not initialized"+hb_eol())
ELSEIF hb_inetErrorCode( oFTP:SocketCon ) == 0
logdebug("Server response: "+hb_ntos(oFTP:cReply)+hb_eol())
ELSE
logdebug("Error in connection: "+hb_inetErrorDesc( oFTP:SocketCon )+hb_eol())
ENDIF
lRetVal := .F.
ENDIF
cEndTime := Time()
logdebug("FTP "+DToC(Date()),cStartTime,cEndTime,ElapTime(cStartTime,cEndTime))
ErrorLevel( iif( lRetVal, 0, 1 ) )
RETURN lRetVal
/* code ends */
/* code begins */
STATIC FUNCTION ftpDB(aFiles)
LOCAL cStartTime := Time(), cEndTime :=""
LOCAL cServer := "ftp.abc.com" , cUser := "j...@ujayadev.com", cPassword := "Table@chair3"
LOCAL lRetVal := .F.
LOCAL cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer
LOCAL oUrl := TUrl():New( cUrl )
LOCAL oFTP := TIPClientFTP():New(oUrl , .t. ) //TIPClientFTP():New( oUrl, .F. )
LOCAL i := 0
oFTP:nConnTimeout := 20000
oFTP:bUsePasv := .T.
oFTP:oUrl:= TUrl():New( cUrl )
oFTP:oUrl:cPassword:= cPassword
oFTP:oUrl:cServer:= cServer
IF oFTP:Open( /*NOTHING HERE*/ ) /* fails here ? */
...
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/000701d76e5e%24ec60b160%24c5221420%24%40com.
Hi,
>>Using Curl is straightforward and works as expected, as well as being able to find a lot of information.
Looks very promising, Do you have some sample on how we can access curl from within the program ? what hbc to link etc.
Thanks for your help.
Warm regards,
Jayadev
From: harbou...@googlegroups.com
[mailto:harbou...@googlegroups.com] On Behalf Of CNavarro
Sent: 02 July 2021 02:03 AM
To: Harbour Users
Subject: Re: [harbour-users] FTP fails when there is an '@' in the user
name or password
Using Curl is straightforward and works as expected, as well as being able to find a lot of information.
To unsubscribe from this group and stop receiving emails from it, send an email
to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/40292478-4175-4257-b3b8-84f7b779729dn%40googlegroups.com.
Hi,
Interesting, could you please elaborate a little more on this.
Warm regards,
Jayadev
From:
harbou...@googlegroups.com [mailto:harbou...@googlegroups.com] On
Behalf Of jgt
Sent: 02 July 2021 03:00 AM
To: Harbour Users
Subject: Re: [harbour-users] FTP fails when there is an '@' in the user
name or password
Depending upon the security, you could use a .netrc file that contains the site, user and password.
To unsubscribe from this group and stop receiving emails from it, send an email
to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/afe88ade-18ea-4f3e-bcd8-fd8c2bdff42en%40googlegroups.com.
Hi Fausto,
Thanks so much for your reply. I will try during the day.
Warm regards,
Jayadev
From:
harbou...@googlegroups.com [mailto:harbou...@googlegroups.com] On
Behalf Of Fausto Di Creddo Trautwein
Sent: 02 July 2021 03:24 AM
To: harbou...@googlegroups.com
Subject: Re: [harbour-users] FTP fails when there is an '@' in the user
name or password
Hi,
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/321ace40-ed4c-62e4-c36c-b40d37fa6a21%40gmail.com.
Hi,
Thanks so much for the sample.
Warm regards,
Jayadev
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/e378242e-3f5f-4b0c-91cd-734fe431a63dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/003001d76efa%24159a6bc0%2440cf4340%24%40com.