I like to thank everyone who responded to this. The problem was that getlogin() was returning NULL and I wasn't checking for it. When script runs it open /dev/ptyX as a tty which of course isn't in utmp. I have taken the advice to use it based upon uid. Dennis