RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
升级列表自动生成脚本

一个自动生成升级文件列表的脚本,可以运行在WIN或者linux

为企业提供网站设计制作、网站设计、网站优化、全网营销推广、竞价托管、品牌运营等营销获客服务。成都创新互联公司拥有网络营销运营团队,以丰富的互联网营销经验助力企业精准获客,真正落地解决中小企业营销获客难题,做到“让获客更简单”。自创立至今,成功用技术实力解决了企业“网站建设、网络品牌塑造、网络营销”三大难题,同时降低了营销成本,提高了有效客户转化率,获得了众多企业客户的高度认可!

要判断中间的版本号,取最大的

文件最终样式如下


productname:ABCikn7
version:2.23.81
uname:ABCikn7_2.23.81_20120101.upt
usize:3598290
dname:ABCikn7_2.23.81_20120101.dd5
dsize:33
url1:ftp://ftp.163.com/down/

productname:xx001A
version:4.0.4
uname:xx001A_4.0.4_20131114.upt
usize:14008320
dname:xx001A_4.0.4_20131114.dd5
dsize:40
url1:ftp://ftp.163.com/down/
url2:ftp://ftp.265.com/down/

#!/usr/bin/ruby
require 'net/ftp'
ip = ["1.2.3.4","2.11.12.2"] #server IP add
url = ["url1:ftp://ftp.163.com/down/","url2:ftp://ftp.265.com/down/"]
update_file = ["e:\\update.txt", "/tmp/update.dat"] #Win or Linux
file_hash = {}
text = ''
def os_family 
  case RUBY_PLATFORM 
    when /ix/i, /ux/i, /gnu/i, 
         /sysv/i, /solaris/i, 
         /sunos/i, /bsd/i 
      "unix" 
    when /win/i, /ming/i 
      "windows" 
    else 
      "other" 
  end 
end
if os_family == "unix"
    text_file = update_file[1]
elsif os_family == "windows"
    text_file = update_file[0]
else puts "unkown os"
    Process.exit(1)
end
def file_list(ip)
    #get ftp dir list
    files = []
    ip.size.times{|x|
        ftp = Net::FTP.open(ip[x])
        ftp.login('username','password')
        ftp.passive = true
        files << ftp.list('down')
        ftp.close
    }
    return files
end
def key_values(type,n,name_size) #get type_x.x.x_date.upt
    dd, up = '', ''
    if n == 1
        regexp = "#{type}_\\d+\\.\\d+\\.\\d+_\\d+."
    else
        regexp = "#{type}_\\d+\\."
    end
    2.times {
        name_size.each_key { |m|
            if /#{regexp}dd5/.match(m)
                dd = m.to_s
            elsif /#{regexp}upt/.match(m)
                up = m.to_s
            end
        }
    }
    return dd, name_size[dd], up, name_size[up]
end
def formatstr(dd,dd_size,up,up_size)   
    type, ver = '', ''
    tmp = []
    tmp = dd.split('_')
    type = tmp[0]
    ver = tmp[1]
msg =<            
            
                                                            
网站栏目:升级列表自动生成脚本
新闻来源:http://scyingshan.cn/article/jjdioi.html