FTP Question

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
User avatar
serge_girard
Posts: 2316
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 555 times
Been thanked: 116 times
Contact:

FTP Question

Post by serge_girard » Sat May 11, 2019 2:11 pm

Hello,

I need to upload some files

Code: Select all

oFtp:uploadFile(LOCALFILE, REMOTEFILE) 
to my server and want to add 'file properties/permissions' (value 0600). In PHP this is done with the command

Code: Select all

$cfile = 'somefile.txt');
chmod($cfile, 0600);
Does anybody knows how to do this HMG?

Thx,
Serge

User avatar
andyglezl
Posts: 1149
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 68 times
Contact:

Post by andyglezl » Sat May 11, 2019 2:31 pm

Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
serge_girard
Posts: 2316
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 555 times
Been thanked: 116 times
Contact:

Post by serge_girard » Sat May 11, 2019 2:38 pm

Thanks Andrés, but this not what I mean (or want). I need a CLIPPER/HARBOUR/HMG command/function like this:

See my example:

Code: Select all

oUrl            := tUrl():New()
oUrl:cProto     := 'ftp'
oUrl:cServer    := x_FTP_SERVER
oUrl:cPath      := ''    
oUrl:cFile      := ''    
oUrl:cUserid    := X_FTP_USER
oUrl:cPassword  := X_FTP_PASSW
oFtp            := tIPClientFtp():New( oUrl )

CC := 0
DO WHILE .T.
   IF oFtp:open()
      EXIT
   ELSE
      CC++
      IF CC >= 4
         ?  "NO FTP connection   ", oFtp:lastErrorMessage() 
         RETURN .F.
      ELSE
         IF 'TIMEOUT' == ALLTRIM(UPPER(oFtp:lastErrorMessage()))
            ?  "FTP TIMEOUT   ", oFtp:lastErrorMessage() 
         ENDIF
      ENDIF
   ENDIF
ENDDO

IF .NOT. oFtp:open()
   ? oFtp:lastErrorMessage()
   RETURN
ENDIF 



LclFileM  := "myfile.txt"
RmtFileM	 := '/my_domain/files/myfile.txt'
 
? 'RmtFileM',  RmtFileM 
? 'LclFileM',  LclFileM 
 
IF FILE(LclFileM)
   IF .NOT. oFtp:uploadFile(LclFileM, RmtFileM)  // here I need to chmod(RmtFileM, 0600);
      MSGINFO('Unable to upload' ) 
   ENDIF
ENDIF

Serge

User avatar
mol
Posts: 3195
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 214 times
Been thanked: 120 times
Contact:

Post by mol » Sat May 11, 2019 3:23 pm

Try to upload php file and execute it

User avatar
andyglezl
Posts: 1149
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 35 times
Been thanked: 68 times
Contact:

Post by andyglezl » Sat May 11, 2019 3:39 pm

mmm... no puedo probarlo, pero tal vez sería así ?
*--------------------------------------------------------------------
mmm ... I can not prove it, but maybe it would be like that ?


cMsgShell:=SHELLEXECUTE( 0, "open" , "ICACLS.exe", "RmtFileM /grant:r User:PermissionM" )
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
serge_girard
Posts: 2316
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 555 times
Been thanked: 116 times
Contact:

Post by serge_girard » Sat May 11, 2019 4:33 pm

Uploading always results in -rw-r-r- (644) , User:read+write. Group:read. World:read.
I made a small PHP program that is called after my upload, which set the file permissions.
This, of course, works fine but requires a second step in the process.

Andrés, ICALCLS.EXE is for Windows and my server is Linux based!

Serge

Post Reply