#!/bin/bash login=erg-admin password=$(< password-admin.txt) token=$(curl "https://pads.erg.be/oidc/token" -X POST -H 'content-type: application/x-www-form-urlencoded' --data grant_type=client_credentials --data client_id="$login" --data client_secret="$password" -s | jq .access_token -r) listAllPads_array=($(curl -s "https://pads.erg.be/api/1.2.1/listAllPads" -H "Authorization: Bearer $token" | jq '.data.padIDs[]' -r)) numberOfPads=${#listAllPads_array[@]} i=1 for padID in "${listAllPads_array[@]}" do echo $i "/" $numberOfPads ((i+=1)) no_publish=$(curl -s "https://pads.erg.be/api/1/getText?&padID=$padID" -H "Authorization: Bearer $token" | grep "__NOPUBLISH__") if [ -n "$no_publish" ] then echo "you cannot access this pad : "$padID else echo "do you stuff on this pad" # do stuff fi done