I have a script that runs on a network of systems. There is a feature in the script that allows users to connect to other systems. I want to disallow some features of the script if the user is already calling the script from a remote system (eg. calling script from telnet/ssh/konsole/xterm session.)
Is there a way to check from the shell to see if my session is remote or local? I used to use 'who am i' as a way to discover this but infortunately it doesn't work in X windows. I tried playing around with searching for the parent of $PPID (bash reserved variable) but this can get muddled since they can call any range of apps to connect remotely and I would have to exclusively search for them. I even tried calling up the terminal type attached to the shell via 'tty' but "pts/*" will show as my tty from a local X session or when connected remotely via telnet/ssh/konsole/xterm.
I basically want to...
Code:
if [ $detected_type_of_session -eq $true_condition ]; then
runcodehere
else
runcodethere
fi
Please help!