閱讀342 返回首頁    go 英雄聯盟


查詢已訂閱的鏡像市場鏡像信息__腳本使用示例_用戶指南_命令行工具 CLI-阿裏雲

您可以利用命令行工具,通過如下腳本,查詢已訂閱的鏡像市場鏡像信息(鏡像 ID 和鏡像名稱)。您可選擇下載腳本或編輯腳本內容。

點擊下載腳本:querySubscribedImageId.zip

腳本內容如下:

  1. `#!/bin/bash
  2. tcount=`aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --output json --filter TotalCount`
  3. pageNum=1
  4. cat /dev/null >/tmp/imageids.txt
  5. while ((tcount>0))
  6. do
  7. aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --filter Images.Image[*].ImageId --PageSize 100 --PageNumber $pageNum --output json --filter Images.Image[*].ImageId | sed '1d' | sed '$d' | sed 's/,//g' | sed 's/"//g'| sed 's/ //g'>>/tmp/imageids.txt
  8. let pageNum++
  9. let tcount-=100
  10. done
  11. cat /tmp/imageids.txt | while read line
  12. do
  13. isSubscribed=`aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --ImageId $line --filter ImageIds.Image[*] --filter Images.Image[*].IsSubscribed --output json | sed '1d' | sed '$d' | sed 's/ //g'`
  14. if [[ $isSubscribed = "true" ]];then
  15. echo $line `aliyuncli ecs DescribeImages --ImageOwnerAlias marketplace --ImageId $line --filter ImageIds.Image[*] --filter Images.Image[*].ImageName --output json | sed '1d' | sed '$d' | sed 's/ //g'` >>imagesInfo.txt
  16. fi
  17. done
  18. native2ascii -encoding UTF-8 -reverse imagesInfo.txt imagesInfoCN.txt
  19. rm -rf imagesInfo.txt
  20. cat imagesInfoCN.txt`

編輯或下載腳本並賦權(chmod +x)後,您可以通過如下格式直接執行腳本,即會在腳本所在目錄下生成包含已訂閱鏡像的信息文件 imagesInfoCN.txt。

用法示例:

  1. ./querySubscribedImageId.sh

輸出示例:

  1. # ./querySubscribedImageId.sh
  2. m-23917oqoi "ASP/.NET 運行環境(Windows200864 位|IIS7.0)V1.0"
  3. m-23n2589vc "Java 運行環境(Centos64 位|OpenJDK1.7)V1.0"
  4. m-23u9mjjtk "PW 建站係統(Centos64 位)V1.0"

最後更新:2016-11-23 16:04:16

  上一篇:go 命令行工具的簡單 Shell 腳本__腳本使用示例_用戶指南_命令行工具 CLI-阿裏雲
  下一篇:go 查詢指定區域下所有實例 ID 並輸出到文件__腳本使用示例_用戶指南_命令行工具 CLI-阿裏雲