I'm pulling my hair out over this. I've looked over all of the google results for /dev/tty : no such device or address, none of them apply to what I am doing / none of the solutions are successful.
I have a script that ssh'es into another machine (using public keys) and runs itself (with different parameters - it doesn't loop). Call this rpmInstallScript.bash
At one point in the script, it runs rpm -ivh to install some RPM packages. During the install of one of these packages, a file is put in /var/tmp called rpm-tmp.[6 random characters]
This file is a script, and I guess it's executed at some point during the rpm install.
In the script, there are multiple occurrences of
echo [something] > /dev/tty
echo [something] | tee [something] > /dev/tty.
All of these occurrences fail with /dev/tty: no such device or address. If I ssh into the machine manually and either rpm the packages myself, run the rpm-tmp script or run rpmInstallscript.bash, it works fine.
I am connecting to the remote machine with ssh -t, therefore there should be a tty, correct?
I don't see why this isn't working, especially because doing it manually, even without the -t option, works fine. The only thing I can think of is that it's not an interactive session - but /dev/tty should still exist, correct?
Edit - the error results from :
ssh -t root@[machine] -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null <<DONE ./rpmInstallScript.bash
where rpmInstallScript.bash runs rpm -ivh, the resulting script placed in /var/tmp uses >/dev/tty - this is what fails
Edit again : using -tt gives :
tcgetattr: Inappropriate ioctl for device
Only when running from a script - manually running ssh -tt and then echo test >/dev/tty works fine.
I can only assume this is a failure to force-create a tty.
Is there any other way to 'generate' a tty? Can I just spoof it by making a file called /dev/tty?