Gav, That worked great thanks. I know it's a small thing but is there a way of stopping the ps -A | grep "$PPID.*aterm$" line echoing to the terminal? Regards Phil