AWS Setup p2 error : syntax error near unexpected token `newline’

I am currently doing setup of AWS for course part 1 , I  managed to get to some place but, I kept on getting this error when I try to execute the bash, below is the error. I manged to fix it, hence below is the solution for everyone’s benefit.

bash 7: syntax error near unexpected token `newline' line 7: `<!DOCTYPE html>'

Why the ” error near unexpected token `newline’ ” ?

The simple reason is that when you do the wget, it is downlading the HTML file that has the <!Doctype html>, so thats the error. When you try to the below with wget, the wget is downloading the html of the github or the other place, so it keeps giving this error.


How to fix the error ?

It is simple, you download the file and the entire folder of the setup (  as there are dependent files and then run them locally. Meaning you just type bash and drag the file in the terminal of mac, it will work.

That’s it folks, did you had any issues ?


  1. jMe

    I was having the same problem, I ended up deleting the downloaded setup_p2 and setup_instance files then downloaded (wget) the raw files from github, then ran setup_p2 again – this seemed to work

    Also best wait til you have the p2 permissions from Amazon before running it

  2. I’m sorry but this doesn’t speak to running this on a windows machine. I pulled all of the files down from github into the same directory in which is saved, but I still get the newline error.


Leave a Comment