cancel
Showing results for 
Search instead for 
Did you mean: 

stdin: is not a tty

Ross Minkov
Esteemed Contributor

stdin: is not a tty


When I send commands remotely over ssh to some Linux servers I get a message printed to stderr -- "stdin: is not a tty”. I don't want to see this message, but I want to see any other error messages printed to stderr (I want to know if I for example make a typo). So I don't want to use “2>/dev/null” at the end as it will hide all of the the stderr.
So, what is the best way to avoid the "stdin: is not a tty” message?

For example:

[user@server1 user]$ ssh server2 uptime
5:47pm up 35 days, 16:42, 0 users, load average: 3.78, 3.23, 3.72
stdin: is not a tty


I can add "-t" to ssh to force pseudo-tty allocation, and that will take care of the "stdin: is not a tty” message, but then I get another message that I don't want: “Connection to server2 closed.”

For example:

[user@server1 user]$ ssh -t server2 uptime
5:49pm up 35 days, 16:44, 1 user, load average: 3.92, 3.51, 3.76
Connection to server2 closed.


I also tried playing with the mesg command, but that didn’t seem to make any difference.

Any ideas?


TIA,
Ross
6 REPLIES
RAC_1
Honored Contributor

Re: stdin: is not a tty

did you try ssh -q option??
There is no substitute to HARDWORK
Ross Minkov
Esteemed Contributor

Re: stdin: is not a tty

Yes, I tried "ssh -q server2 uptime" and still got the "stdin: is not a tty" message.
Ross Minkov
Esteemed Contributor

Re: stdin: is not a tty

Oh, wait... Here is the solution: use both -q and -t. I only tried them separately b4...


Example 1 -- typo in command, a "command not found" message is printed to stderr:

[user@server1 user]$ ssh -tq server2 uptimme
bash: uptimme: command not found


Example 2 -- command syntax is ok and execution completes successfuly; prints result to stdout:

[user@server1 user]$ ssh -tq server2 uptime
7:25am up 4 days, 19 min, 1 user, load average: 10.62, 9.97, 7.86


Thanks,
Ross
Ross Minkov
Esteemed Contributor

Re: stdin: is not a tty


Solution to the issue was to use both -t and -q:

-q --> Quiet mode. Causes all warning and diagnostic messages to be suppressed.

-t --> Force pseudo-tty allocation.



Felipe Formiga
Occasional Visitor

Re: stdin: is not a tty

Hi all

Try run this one
-----
#!/bin/bash
TEST1=`pwd > /tmp/test1.txt`
TEST2=`ssh -tq brazil03 "cd /home/fsf/tmp/script && pwd" > /tmp/test2.txt`
TEST1B=`cat /tmp/test1.txt`
TEST2B=`cat /tmp/test2.txt`

if [ $TEST1B = $TEST2B ]; then
echo WORK!!!!!!!
echo $TEST1B
echo $TEST2B
else
echo DOES NOT WORK!!!!!
echo $TEST1B
echo $TEST2B
fi
exit 0
-----

What is different?
When a do not use "-tq" ssh option, it work properly.

Felipe Formiga
Occasional Visitor

Re: stdin: is not a tty

Please, use "localhost" instead of "brazil03"