Frage

This is a dumb question but please help me.

Q. How do I run Python script that is saved in my local machine?

after vagrant up and vagrant ssh, I do not see any Python file in the VM. Then what if I want to run Python scripts that are saved in my Mac? I do not want to copy and paste them manually using vim.

How would you run Python script in Vagrant ssh?

War es hilfreich?

Lösung

On your Guest OS there will be a folder under / called /vagrant/ this will be all the files and directories under the directory on your host machine that contains the .VagrantFile

If you put your script in that folder they will be shared with the VM.

Additionally if you are using chef as your provisioner you can use a script resource to run external scripts during the provisioning step.

Andere Tipps

You have two options:

  1. You can go the classic route of using the shell provisioner using vagrant

    config.vm.provision "shell", inline: $script

And in your script run the python script

  1. All files are pushed in /tmp, you can possible use this to run your python script
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top