Thanks for the help Russ, You are quite correct - the EOF must go in the first collumn, however I still get weird results, simplified script below - I would expect it to print ls twice, but it prints it once and gives a directory listing the second time! -Steve