This bash script is supposed to fetch a token from elsewhere via ssh, then run a curl command where it reads data from a file on stdin.
#!/usr/bin/env bash TOKEN=$(ssh somewhere cat sometoken.txt) curl https://example.com \ -H "Authorization: Bearer $TOKEN" \ -H "someparam=@-" \ -X POST
And the script is called like this:
cat somefile | myscript
When I hardcode
TOKEN=abcd123 instead of using
somefile is uploaded as expected by curl.
However when I use
$(ssh ...) my file is not uploaded.
I assume that my script's stdin is being clobbered by
$(ssh ...) but I can't see how to work around that.
Any help would be much appreciated.