Answer the question
In order to leave comments, you need to log in
Does Linux/*BSD have a generic command to determine the console?
Hello. How can I automatically determine in which environment the command is run - in a console with the ability to access the X display and run GUI applications, or remotely? For example:
$ who
bob tty7 2018-02-20 19:32 (:0)
bob pts/0 2018-02-25 09:48 (126.126.68.117)
Answer the question
In order to leave comments, you need to log in
Checking showed that tty gives /dev/pts/N both remotely and locally.
You can check for a remote SSH session by setting the $SSH_CLIENT environment variable. And since almost no one works using the telnet protocol (I don’t know any other connection options), you can use this as a solution to the issue.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question