Fixed error when calling pgw.sh from Python by moving all of the tput commands into a function which is only called in interactive mode