tty --help command is executed it shows
Usage: tty [OPTION]...
Print the file name of the terminal connected to standard input.
-s, --silent, --quiet print nothing, only return an exit status
--help display this help and exit
--version output version information and exit
tty -s is executed it returns nothing
When is useful use
I thought maybe in a script it would not show any output but the return code would contain the value it would normally show. I tested that but it doesn’t. Just shows a 0 return.
I looked at the source code
This file has been truncated.
/* tty -- print the name of the terminal connected to standard input
Copyright (C) 1990-2005, 2008-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Displays "not a tty" if stdin is not a terminal.
Displays nothing if -s option is given.
Exit status 0 if stdin is a tty, 1 if not, 2 if usage error,
3 if write error.
It does indeed display nothing with the
but i think it returns 0 if the terminal is a tty
and 1 if the terminal is not a tty
@pdecker tried it and it returned zero… does that mean he was using a tty terminal?
I am not sure
$ tty -s
$ echo "$?"
So it thinks /dev/pts0 is a tty ??
Hello to all.
Pls let me try your suggestions in both environments, GUI and server.
I am using the Window Terminal available by default on Ubuntu Desktop and Fedora Workstation. So not server environment, but it is going to be test it.
Best to all.