Question

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
Was it helpful?

Solution

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"

OTHER TIPS

On OS X, I solved a similar problem (for script provisioning on Vagrant) with ssh -t -t (note that -t comes twice). Advice based on the ssh BSD man page:

-T Disable pseudo-terminal allocation.

-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

If running tcsh is not important for you, specify a different shell and it will work:

ssh -T user@server bash << EOF
cd cs4400/$dest
gcc -o $efile $file
./$efile
EOF
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top