0

I want to run the following command:

curl -X PUT $URL -H "accept: */*" -H "Content-Type: application/json" -d '{"payload": $(base64 /some/path)`}'

I'm having trouble running the command in ESLinux environment (tcsh) because it can't execute $(base64 /some/path). Getting Illegal variable name which makes sense because using this syntax is bash and not tcsh. How can I execute it? Tried to use backticks but didn't work.

1 Answer 1

0

Backticks should work. Note you need some more double quote characters to get the json syntax correct

curl -X PUT $URL -H "accept: */*" -H "Content-Type: application/json" -d '{"payload": "'`base64 /some/path`'"}'

The -d parameter is built up in 3 pieces

   '{"payload": "'
   `base64 /some/path`
   '"}'

The first and third use single quotes, so everything inside them is preserved, including the double quotes. In particular the final value for the -d parameter will look like { "payload": "af5143676d6d6d6a bcdefc8844"} with the double quotes around the hex string and with embedded spaces replacing the newlines in the output of base64. The far end may not like the spaces.

1
  • base64 -w0 /some/path
    – user313992
    Jan 27, 2021 at 0:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .