다음 스크립트를 실행했지만 구문 오류가 발생합니다: 예기치 않은 리디렉션
#!/bin/sh
# Bash strict mode, stop on any error
set -euo pipefail
# Ensure all required environment variables are present
test -n "$DATABRICKS_WORKSPACE_RESOURCE_ID"
test -n "$KEY_VAULT"
test -n "$SECRET_NAME"
test -n "$ARM_CLIENT_ID"
test -n "$ARM_CLIENT_SECRET"
test -n "$ARM_TENANT_ID"
# Login
az login --service-principal -u "$ARM_CLIENT_ID" -p "$ARM_CLIENT_SECRET" -t "$ARM_TENANT_ID"
# Get a token for the global Databricks application.
# The resource name is fixed and never changes.
token_response=$(az account get-access-token --resource 2ff814a6-3304-4ab8-85cb-cd0e6f879c1d)
token=$(jq .accessToken -r <<< "$token_response")
# Get a token for the Azure management API
token_response=$(az account get-access-token --resource https://management.core.windows.net/)
azToken=$(jq .accessToken -r <<< "$token_response")
# Generate a PAT token. Note the quota limit of 600 tokens.
api_response=$(curl -sf $DATABRICKS_ENDPOINT/api/2.0/token/create \
-H "Authorization: Bearer $token" \
-H "X-Databricks-Azure-SP-Management-Token:$azToken" \
-H "X-Databricks-Azure-Workspace-Resource-Id:$DATABRICKS_WORKSPACE_RESOURCE_ID" \
-d '{ "comment": "Terraform-generated token" }')
pat_token=$(jq .token_value -r <<< "$api_response")
az keyvault secret set --vault-name "$KEY_VAULT" -n "$SECRET_NAME" --value "$pat_token"
어떻게 작동하게 만들 수 있는지 아시나요?
답변1
<<< "$token_response"
POSIX는 이러한 문자열을 지원하지 않습니다./bin/sh
예를 들어 이를 지원하는 쉘로 전환하거나 /bin/bash
명령을 다음과 같이 수정하십시오.
pat_token=$(printf '%s\n' "$api_response" | jq .token_value -r)