Reputation: 28951
I want to run the following commands in one line:
$ curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O
$ python ./awslogs-agent-setup.py --region eu-west-2
How can I do this?
I tried the following
$ curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -s | python --region eu-west-2
But I get the error:
Unknown option: --
Upvotes: 4
Views: 2685
Reputation: 117
Why not just use &&
curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O && python ./awslogs-agent-setup.py --region eu-west-2
and if you want to do without creating a file just to delete later, do this:
curl -s https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py | python /dev/stdin --region eu-west-2
Upvotes: 0
Reputation: 85895
You could let the python
interpreter read from stdin
using /dev/stdin
(similar to python -
) and pass the additional arguments alongside.
curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -s |\
python /dev/stdin --region eu-west-2
As Barmar points out using /dev/stdin
could be OS specific in which case using python -
would be more standard
curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -s |\
python - --region eu-west-2
As curl
outputs the file content to stdout, you can pipe it over to the standard input of the interpreter.
Or use process-substitution feature in bash
(<()
), which lets you treat the output of a command as if it were a file to read from
python <(curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -s) --region eu-west-2
Upvotes: 6