Thanks for the help, everyone. The problem appears to have been the line-end character. Moving the script around a mixed PC/Unix environment must have left it in the wrong format, but the "here" document was the only place it mattered. Opening the script file in "TextPad" and then saving it with a format forced to PC cured the problem.