LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   TERM=linux for serial port (https://www.linuxquestions.org/questions/linux-general-1/term%3Dlinux-for-serial-port-586349/)

powah 09-21-2007 10:29 AM

TERM=linux for serial port
 
I want to find out whether a user is logged into my computer through the RS232 serial port.
For FC6 (kernel 2.6.18-1.2798), the environment variable
TERM will be set to "linux" for serial port login.
Isn't it?
For all types of log in, then TERM will be set to something else, right?

wjevans_7d1@yahoo.co 09-22-2007 08:16 PM

Don't rely on the TERM variable to help you out here. You might have TERM set to linux in other situations also.

I'm not the most qualified person to answer this, because almost all my experience has been on Slackware. But it might help. I'm answering because nobody has answered you for more than a day. Maybe any misinformation I give you might spur someone else to give a real answer.

On Slackware, there's a file called "/etc/inittab". Among other things, it contains information about all the non-X ways you can log in. Search it for the word "serial". Close to that word, you should see the names of the tty devices which are used for serial port login. (Any which start with "#" have been commented out, and don't count.) On my system, I see "ttyS0" and "ttyS1" as those two devices.

If /etc/inittab isn't there on your distribution, try this at the command line:
Code:

grep -lr tty6 /etc 2> /dev/null
and look through the resultant list for the appropriate file.

Then, if you're in a script or at the command line, do this:
Code:

ls -l /proc/$$/fd/0
and see whether the device named in the symbolic link matches one of the serial login devices.

In C or elsewhere, do the programmatic equivalent.

Hope this helps.


All times are GMT -5. The time now is 02:51 AM.