執行ruby腳本報錯
O.A.O.A
O.A.O.A 2018-10-09 16:22:31
0
0
1388

/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)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!