## 3.13. Terminal Setup: Testing Port

If you know that certain port (tty) numbers are used for certain kinds of logins, you can test that and change your terminal setup based on the tty you're currently using. For example, some systems use ttyp0, ttyq1, etc. as network ports for rlogin and ssh (Section 1.21), while others use pty0, etc. This Bourne-type case statement branches on the port name:

`tty` Section 2.7

>     case "`tty`" in
>     /dev/tty[pqrs]?)
>        # rlogin, telnet:
>        ...
>     /dev/tty02)
>        # terminal on my desk:
>        ...
>     "not a tty") ;;  ...not a terminal login session; do nothing
>     esac

In C-type shells, try a switch or if statement instead.

On Linux, you may need to look for patterns to match /dev/pts/0, /dev/pts/1, etc.

--JP and SJC

Copyright © 2003 O'Reilly & Associates. All rights reserved.