0

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?

4
  • try using ssh to execute a script in the remote server. Commented Apr 18, 2018 at 16:34
  • Is there a way to prevent ssh ? I can share script with my team but not access into my VM. I’m trying to create a separation Commented Apr 18, 2018 at 16:35
  • 1
    Are you trying to store the script on the server, but run it locally? Or do you want to run the script on the server as well? Commented Apr 18, 2018 at 16:39
  • I want to store the script a Remote VM so I can run from other VMs or even locally. Commented Apr 18, 2018 at 16:41

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.