[olug] am I at the console?
Sean Kelly
smkelly at zombie.org
Sun Mar 26 01:11:19 UTC 2006
On Fri, Mar 24, 2006 at 05:44:34PM -0500, thelarsons3 at cox.net wrote:
> Hello,
>
> I want a shell script to check if it's being run at the console, so it can act differently than it would in a virtual/remote terminal. Is this possible? A portable (cross-Unix) solution would be great, but I'll take anything.
On my RHEL AS 4 system, I have an /sbin/consoletype command:
RETURN VALUE
consoletype when passed no arguments returns
0 if on virtual terminal
1 if on serial console
2 if on a pseudo terminal.
$ /sbin/consoletype >/dev/null ; echo $?
2
# /sbin/consoletype < /dev/tty1 > /dev/null ; echo $?
0
--
Sean Kelly | PGP KeyID: D2E5E296
smkelly at zombie.org | http://www.zombie.org
More information about the OLUG
mailing list