The problem is the space between the = and the command. Change the line to ALTCOURSE=`head ....
What's happened is that bash interprets the space as a delimiter, and is setting ALTCOURSE to nothing, running the command specified in the backticks and then attempting to run the resulting value as a program. By removing the space, the value will be stored in ALTCOURSE as expected.
You'll also need to change the other lines where you've got spaces around the = sign.
As a quick side point, please use the code tags when you post code. It preserves the indentation and generally makes the post easier to read.