-2

If command1 is:

curl -k -v -u user:password https://example.com/v2/image/manifests/tag -H Accept: application/vnd.docker.distribution.manifest.v2+json 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}' 

which output, for example, the following Docker-Content-Digest:

> sha256:12345...

knowing that running each command separately works, how to inject command1 output as part of command2 text as:

curl -k -v -u user:password -X DELETE https://example.com/v2/image/manifests/(command1 output)

I am just trying to run one command only!


Update:

When I combine them together using the double quote as following:

curl -k -v -u user:password -X DELETE https://example.com/v2/image/manifests/"$(curl -k -v -u user:password https://example.com/v2/image/manifests/tag -H Accept: application/vnd.docker.distribution.manifest.v2+json 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}')"

I get the following output and command2 never executed:

> * Illegal characters found in URL
> * Closing connection -1 
> * curl: (3) Illegal characters found in URL

Update 2

when I use single quote, I get the following output:

> < HTTP/1.1 404 Not Found 
< Server: nginx/1.21.3 
< Date: Tue, 28 Sep
> 2021 13:46:50 GMT 
< Content-Type: text/plain; charset=utf-8 <
> Content-Length: 19 
< Connection: keep-alive <
> Docker-Distribution-Api-Version: registry/2.0 <
> X-Content-Type-Options: nosniff < 404 page not found
13

1 Answer 1

0

I assume you mean:

echo "thisis $(echo 'test')"

Depending on what you actually want to achieve, you can try a bunch of things:

  1. You can substitute each part of the command pipe and see where the error is. So far, you didn't do any actual debugging, as far as I can see.

  2. You could simply assign the output of the first command into a variable:

CMD1=$(curl -k -v -u user:password https://example.com/v2/image/manifests/tag -H Accept: application/vnd.docker.distribution.manifest.v2+json 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}')
curl -k -v -u user:password -X DELETE https://example.com/v2/image/manifests/"$CMD1"

Obviously I can't debug any of that, as I don't have access to the actual result set of either command - that's for you to try and debug further.

I any event, the $(…) syntax is called command substitution, and it's explained in the man pages of shells that support it (which is pretty much every single modern one).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.