-
-
Save jenya239/8ff79e1023c6ed546459a8a6bcc19282 to your computer and use it in GitHub Desktop.
ruby ftp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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