curl command output used in a script.


Run the curl command and extract the login names, ids, created, lastLoginTime and associated groups

response=(curlsH"Authorization:ETX(curl -s -H "Authorization: ETX {API}" -X GET "https://server.name.co.com:8443/etx/api/v2/users?where_role=User&where_status=0")

if echo "response" | jq -e . >/dev/null 2>&1; then echo "response" | jq -r 'map(select(.groups != null)) | .[] | "(.id),(.login),(.name),((if (.created|type) == "string" then .created | strptime("%Y-%m-%d %H:%M") | strftime("%Y-%m-%d %H:%M:%S") else "N/A" end)),((if (.lastLoginTime|type) == "string" then .lastLoginTime | st
rptime("%Y-%m-%d %H:%M") | strftime("%Y-%m-%d %H:%M:%S") else "N/A" end)),(.groups | map(.name) | join(", "))"' > "$etx_users_file"
else
echo "Error: API response is not valid JSON."
exit 1
fi