code-8
code-8

Reputation: 58730

Run remote Python script via curl

I have a Python file where I can just run like this locally

script.py --ip=172.19.242.32 --mac=102030405060

Now I upload the script to my VM IP: 45.55.88.55.

How can I call the script via cURL and pass in proper flags?

I've tried

curl 45.55.88.55/script.py  | python --ip=172.19.242.32 --mac=102030405060

and

curl 45.55.88.55/script.py --ip=172.19.242.32 --mac=102030405060  | python 

Both are not working. How can I debug this further?

Upvotes: 0

Views: 672

Answers (2)

antzshrek
antzshrek

Reputation: 9943

As @Barmar rightly said, Instead of running

curl 45.55.88.55/script.py  | python --ip=172.19.242.32 --mac=102030405060

which will make you miss your argument that is most times needed after whatever script name you're running. Which implies that you will need the short- delimiter character as the name

Upvotes: 1

Barmar
Barmar

Reputation: 781964

Arguments come after the script name. To use standard input as the script, use - as the name:

curl 45.55.88.55/script.py  | python - --ip=172.19.242.32 --mac=102030405060

This is a pretty standard Unix argument convention, although not all programs obey it (mostly older programs).

Upvotes: 1

Related Questions