edit-icon download-icon

Query information of the subscribed image market images

Last Updated: Dec 21, 2017

You can run the following script in Alibaba Cloud CLI to query information (image IDs and names) of all subscribed image market images. You can download or edit the script.

Click to download the script: querySubscribedImageId.zip

The script is as follows:

  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`

After editing or downloading the script and granting the permission (by running the chmod + x command), you can run the script in the following format to generate an imagesInfoCN.txt file containing information of subscribed image market images in the directory storing the script.

Example:

  1. ./querySubscribedImageId.sh

Sample output:

  1. # ./querySubscribedImageId.sh
  2. m-23917oqoi "ASP/.NET runtime environment (Windows 2008 64-bit|IIS7.0) V1.0"
  3. m-23n2589vc "Java runtime environment (Centos 64-bit|OpenJDK1.7) V1.0"
  4. m-23u9mjjtk "PW website construction system (Centos 64-bit) V1.0"
Thank you! We've received your feedback.