Skip to content

Instantly share code, notes, and snippets.

@jenya239
Created April 18, 2019 13:19
Show Gist options
  • Save jenya239/8ff79e1023c6ed546459a8a6bcc19282 to your computer and use it in GitHub Desktop.
Save jenya239/8ff79e1023c6ed546459a8a6bcc19282 to your computer and use it in GitHub Desktop.
ruby ftp
#dumb perms string to int
def process_perm
r =''
n =0
n +=4 if @perms[ 1 ] =='r'
n +=2 if @perms[ 2 ] =='w'
n +=1 if @perms[ 3 ] =='x'
r +=n .to_s
n =0
n +=4 if @perms[ 4 ] =='r'
n +=2 if @perms[ 5 ] =='w'
n +=1 if @perms[ 6 ] =='x'
r +=n .to_s
n =0
n +=4 if @perms[ 7 ] =='r'
n +=2 if @perms[ 8 ] =='w'
n +=1 if @perms[ 9 ] =='x'
r +=n .to_s
@perms_number_string =r
@perms_number =r .to_i( 8 )
end
require 'net/ftp'
Net::FTP.open( 'ip', 'user', 'pass' ) do |ftp|
@ftp =ftp
@ftp .getbinaryfile( @path, @local_path )
end
def get_perms path
n =File.stat( path ).mode & 07777
sprintf( "%o", n )
end
@live .ftp .mkdir @target_dirname
@live .ftp .sendcmd "SITE CHMOD #{ mode } #{ path }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment