执行ruby脚本报错
O.A.O.A
O.A.O.A 2018-10-09 16:22:31
0
0
1427

/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.A
O.A.O.A

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板