0

Trying to add a startup script following the sample here: https://cloud.google.com/compute/docs/startupscript

The instance is created with no problems but the script does not execute. Console shows the following output:

Jul 28 15:54:39 testclient-pbx startup-script: INFO Starting startup scripts.

Jul 28 15:54:39 testclient-pbx startup-script: INFO Found startup-script in metadata.

Jul 28 15:54:39 hostname startup-script: INFO startup-script: /bin/bash: /startup-aVpN6i/tmpVVdFyB: /bin/bash^M: bad interpreter: No such file or directory

Jul 28 15:54:39 hostname startup-script: INFO startup-script: Return code 126.

Jul 28 15:54:39 hostname startup-script: INFO Finished running startup scripts.

I'm actually trying to run more complex script but was receiving same error. Using debian-cloud/debian-9 image.

Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43
RT2 Tech
  • 11
  • 1
  • 3

2 Answers2

1

I'm using VScode on Win platform and as you can see above the message hinted file was not found. I had to change CRLF in VScode to LF "Unix" style and script now runs correctly! In VScode just click the CRLF bottom right and change to LF.

image

alexander.polomodov
  • 1,068
  • 3
  • 10
  • 14
RT2 Tech
  • 11
  • 1
  • 3
1

It looks like you are passing a hidden symbol ^M

I would recommend you to inspect the file with vim and set the following command to show you the hidden characters:

:set list
  • Thank you @miguelfrancisco85. Yes, this would have helped me find the issue. As stated above this was due to file being created in windows platform and using CRLF instead of *nix LF. – RT2 Tech Aug 02 '18 at 12:55