ssh and "stderr is not a tty - where are you?"

I want to apply a sequence of commands to a load of servers. It is a relatively complicated sequence of commands including su-ing as a different user, killing a process, exiting, installing a Slackware package, which has a post-installation script, su-ing as a different user again, starting a daemon, sleeping a couple of seconds and then tailing a log file to check that the daemon is healthy.

To apply the command to many servers, I have a BASH for loop which changes $server and executes the sequence of commands using SSH as follows:

    ssh root@$server "blah; blah; blah"

All I need to do is to paste the root password and I'm in business.

However, one of my commands is throwing up the error: "stderr is not a tty - where are you?". Evidently one of the commands is checking stderr and getting disappointed. Rather than sorting out the command which is the culprit, is there something I can do with SSH to avoid this?
LVL 17
Who is Participating?
cjl7freelance for hireCommented:

I'd do it the other way around...

for i in `cat servers.txt`
cat | ssh root@$server /bin/bash

But I don't know if that helps at all...

I'm using ssh in a simular way, but I use ssh-keys in order to not type passwords...

use -t option to the ssh
ssh -t root@$server "blah; blah; blah"
rstaveleyAuthor Commented:
That works, Jonas. Many thanks. Oddly enough I still see the "stderr is not a tty - where are you?", but it isn't a show-stopper.

> I use ssh-keys in order to not type passwords

I would if I could but I keep losing the argument about that approach with our main admin, who unceremoniously zaps my .ssh/authorized_keys2 entries 8-)
rstaveleyAuthor Commented:
ravenpl, the -t option gets me a warning:

   Pseudo-terminal will not be allocated because stdin is not a terminal.

...and doesn't seem to make any difference otherwise.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.