搜索

首页  >  问答  >  正文

执行ruby脚本报错

/usr/local/lib/ruby/gems/2.1.0/gems/json-2.1.0/lib/json/common.rb:156:in `parse': 765: unexpected token at 'decode() argument 1 must be string, not None (JSON::ParserError)

在终端ruby xxx.rb可以正常执行,但是jenkins页面执行shell时候提示这个错误。ruby代码如下:

#!/usr/bin/env ruby

require 'json'

cmd = "/usr/local/bin/aliyuncli ecs DescribeInstances --output json --PageSize 50 --RegionId "

RegionIds = ["cn-hangzhou","cn-qingdao","cn-beijing","cn-hongkong","cn-shenzhen","us-west-1"]

RegionIds.each do |regionid|

  data = `#{cmd} #{regionid}`

  data = JSON.parse(data)

  data["Instances"]["Instance"].each {|instance| print instance["RegionId"]," ",instance["InstanceName"]," ",instance["PublicIpAddress"]["IpAddress"][0]," ",instance["InnerIpAddress"]["IpAddress"][0],"\n"}

  #puts data

end


O.A.O.AO.A.O.A2271 天前1436

全部回复(0)我来回复

暂无回复
  • 取消回复