Besides 'who am i' and 'tty' what commands could be used to determine if a session is interactive as compared to a web process or cron process. Any command should work with the common unix variants.
maybe you can use : ps -fu username
The command "who am i" and "tty" will both fail when run from cron because there is no terminal context.
This test will tell you whether you have terminal context. See "man test".
if [ -t 1 ]
then
echo "I have terminal context"
else
echo "I do not have terminal context"
fi
The problem was that the program would not run if it was not run from a terminal session.
Read the manual, and found that the terminal can be spoofed with an environment variable. Problem solved.