How Do You Troubleshoot a Bash Script Copied from the Internet?

You have one of the following two problems:

Problem scenario #1
Your GCP startup-script is not working. You do not know why. What should you do?

OR

Problem scenario #2
A bash script is not working. It stops executing after a certain line. There are few clues as to what is wrong.

Solution
Did you copy the script from a webpage? If so the root cause could be the web page you copied it from used a slightly different character for the double quotes. Left double quotation or right double quotation marks will cause a problem. Make sure the quotes are not ” or “. You want just regular quotes like this ".

Notepad, Notepad++, and vi support different double quotes (left, right and straight). Be careful to not use ” or “ unless you know what you are doing in programming. You normally want to use ".

See also this posting.

Leave a comment

Your email address will not be published. Required fields are marked *