Skip to content
Advertisement

Suppress ‘Warning: no access to tty’ in ssh

I have a short simple script, that compiles a .c file and runs it on a remote server running tcsh and then just gives back control to my machine (this is for school, I need my programs to work properly on the lab computers but want to edit them etc. on my machine). It runs commands this way:

ssh -T user@server << EOF
cd cs4400/$dest
gcc -o $efile $file
./$efile
EOF

So far it works fine, but it gives this warning every time I do this:

Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.

I know this technically isn’t a problem, but it’s SUPER annoying. I’m trying to do school work, checking the output of my program etc., and this clutters everything, and I HATE it.

I’m running this version of ssh on my machine:

OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012

This version of tcsh on the server:

tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux)

And this version of ssh on the server:

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010

Advertisement

Answer

The message is actually printed by shell, in this case tcsh. You can use

strings  /usr/bin/tcsh | grep 'no access to tty'

to ensure that it belongs to tcsh itself.

It is related to ssh only very loosely, ie ssh in this case is just the trigger, not the cause.

You should either change your approach and not use HERE DOCUMENT. Instead place executable custom_script into /path/custom_script and run it via ssh.

# this will work
ssh user@dest '/path/custom_script'

Or, just run complex command as a oneliner.

# this will work as well
ssh user@dest "cd cs4400/$dest;gcc -o $efile $file;./$efile"
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement