Ich habe ein Python-Skript auf einer gcloud-VM-Instanz. Ich möchte es über dieses Shell-Skript ausführen:Wie erstellt man ein Shell-Skript, das eine Verbindung zu einer VM herstellt und Befehle ausführt?
gcloud compute instances start instance-1 #start instance
gcloud compute ssh [email protected] #ssh into it
cd project_folder #execute command once inside VM
python my_script.py #run python script
sudo shutdown now #exit instance
gcloud compute instances stop instance-1 #stop instance
Die ersten beiden Befehle funktionieren wie vorgesehen; Der Rest der Befehle wird jedoch nicht auf der VM ausgeführt. Wie kann ich ein Skript erstellen, das nach der Verbindung mit der VM Befehle ausführt?