私はgcloud VMインスタンス上にPythonスクリプトを持っています。私はこのシェルスクリプトを通して実行したい:VMに接続してコマンドを実行するシェルスクリプトを作成する方法は?
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
最初の2つのコマンドは、意図したとおりに動作します。ただし、残りのコマンドはVMでは実行されません。 VMに接続した後にコマンドを実行するスクリプトを作成するにはどうすればよいですか?