Thursday, December 17, 2009

EC2, fabric, and "err: stdin: is not a tty"

Recently, I've been using fabric to script up some deployments to EC2. My EC2 server is running the 32-bit Ubuntu Jaunty 9.04 server image provided by Alestic, but I suspect this issue applies across lots of different OS variants. Fabric seems to work well, but I was getting a nuisance message when running commands on my EC2 instance: err: stdin: is not a tty. You can even see the message in action in the output of this (very useful) intro to fabric that happens to show an EC2 example.

Some searching turned up that this is a result of a command in a .profile or .bashrc on the remove host expecting the shell to be interactive, which it is not with fabric.

In my case, the culprit was /root/.profile, in particular the command mesg n. To fix the message, I wrapped the mesg call in a check for an interactive tty:
if `tty -s`; then
    mesg n

1 comment: