title: How to make a shell script that connects to a VM and executes commands?
body: <p>I have a Python script on a gcloud VM instance. I want to run it via this shell script: </p>
  
  <pre><code>gcloud compute instances start instance-1  #start instance
  gcloud compute ssh my_username@instance-1  #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
  </code></pre>
  
  <p>The first two commands work as intended; however, the rest of the commands don't execute on the VM. How can I make a script that executes commands after connecting to the VM?</p>