Hi!
Try this idea;
If a script needs to test whether it is running in an interactive shell, it is simply a matter of finding whether the prompt variable, $PS1 is set. (If the user is being prompted for input, then the script needs to display a prompt.)
Code:
if [ -z $PS1 ] # what no prompt?
then
# non-interactive; ...
else
# interactive; ...
fi
There are other ideas there in this link:
http://www.tldp.org/LDP/abs/html/intandnonint.html
One more is that if in background/foreground there is a tty-variable that is set or not set. You could also do something like put a special variable in "~./.profile" that shows that the user is online, eg: $PS1 above. (Just ideas: got no references or clearer ideas on these last ones!)
Hope that was helpful
GrahamB