#bash (2020-08)

A channel for bash scripting

2020-08-07

Brij S avatar
Brij S

Hey bash experts!

workspace_id=$(curl -s --header "Authorization: Bearer ${TFE_TOKEN}" --header "Content-Type: application/vnd.api+json" "<https://some/giant/url/here>" | jq -r .data.id)
echo "Workspace ID is ${workspace_id}"

when I run that curl command in shell, it works fine but when I put that into a shell script it just returns null, any ideas why?

bradym avatar
bradym

Most likely is that TFE_TOKEN is not correctly set in the script

I’d do two things to troubleshoot:

set -x before the workspace_id line, and change your curl command to curl -sS so you’ll get any errors from curl that are currently being suppresed.

Brij S avatar
Brij S

that was it! the token wasnt set

Brij S avatar
Brij S

I had it set, but I forgot to use export

:--1:1
bradym avatar
bradym

I’ve done that more times than I care to admit

1
    keyboard_arrow_up