How can I wait until a shell prompt appears before further commands get executed (in a bash script e.g?) on some hosts I can do ssh user@host echo "test"; and it would login, and when ready execute echo "test" - but it looks like it doesn't work on every host. I would like to wait for the # or $ prompt to appear before continuing on to execute echo "test" - how can i do so?
When I do ssh user@host then wait for the # and manually do echo "test" it works as you would expect. How can I put this into a script? ssh user@host -t echo "test" doesn't work either.
I'm particularly trying to do something like: ssh -o StrictHostKeyChecking=no -p 2222 user@host -t tail -f /var/log/MyFile.log i.e. tail a log file of a host and show the result on the local shell
Instead of tailing the log file, it just throws me to the prompt:
No entry for terminal type "screen";
using dumb terminal settings.
#
--> Please ignore that the prompt is root, that's not part of this thread. And yes, it is launched out of a screen session - from a plain terminal (xterm), it says No entry for terminal type "xterm"; (e.g.) instead.
Without -t I get FATAL: not a terminal and it throws me back to the local shell.