linux下ruby脚本安装,Ruby批量执行Linux安装程序和脚本

require 'find'

module Find

def match(*paths)

matched = []

find(*paths) { |path| matched << path if yield path }

return matched

end

module_function :match

end

def ExecuteAllSh(sourcefile)

sourcefile .each do |s|

system("bash \""<< s << "\"")

end

end

def ExecuteAllPl(sourcefile)

sourcefile .each do |s|

system("perl \""<< s << "\"")

end

end

def ExecuteAllRb(sourcefile)

sourcefile .each do |s|

system("ruby \""<< s << "\"")

end

end

def ExecuteAllPy(sourcefile)

sourcefile .each do |s|

system("python \""<< s << "\"")

end

end

def ExecuteAllRpmBinRun(sourcefile)

sourcefile .each do |s|

system("\""<< s << "\"")

end

end

def ExecuteAllClass(sourcefile)

sourcefile .each do |s|

system("java \""<< s[0...-6] << "\"")

end

end

def ExecuteAllBundle(sourcefile)

sourcefile .each do |s|

system("\""<< s << "\"")

end

end

def ExecuteAllJar(sourcefile)

sourcefile .each do |s|

system("java -jar \""<< s << "\"")

end

end

ExecuteAllSh Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".sh"}

ExecuteAllPl Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".pl"}

ExecuteAllRb Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".rb"}

ExecuteAllPy Find.match("./"){ |p| ext = p[-3...p.size]; ext && ext.downcase == ".py"}

ExecuteAllRpmBinRun Find.match("./"){ |p| ext = p[-4...p.size]; ext && (ext.downcase == ".rpm" || ext.downcase == ".bin" || ext.downcase == ".run")}

ExecuteAllClass Find.match("./"){ |p| ext = p[-6...p.size]; ext && ext.downcase == ".class"}

ExecuteAllBundle Find.match("./"){ |p| ext = p[-7...p.size]; ext && ext.downcase == ".bundle"}

ExecuteAllJar Find.match("./"){ |p| ext = p[-4...p.size]; ext && ext.downcase == ".jar"}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值