Skip to main content
Move info into question from comments.; edited tags; edited tags
Source Link
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

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.

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.

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.

edited title
Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75

how to implmentimplement a wait until prompt appears before exection of cmds?

added 227 characters in body
Source Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75

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.

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

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.

added 202 characters in body
Source Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75
Loading
added 199 characters in body
Source Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75
Loading
edited body
Source Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75
Loading
added 280 characters in body
Source Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75
Loading
Source Link
stdcerr
  • 2.1k
  • 14
  • 49
  • 75
Loading