0

I went little crazy...

Here's what I did

 echo `ssh [email protected]`

Then it asked for password and I entered it and later it was struck there.

I expect that echo is blocked here. Is it correct?

Please explain what happened exactly here in a step-by-step way.

1 Answer 1

4

I expect that echo is blocked here. Is it correct?

A command substitution is always processed before the "final" (in this case "outer") command is run.

So echo is not "blocked", but is waiting for the command inside the command substitution to finish its execution, which never happens because the command itself spawns an ssh interactive shell.

You can verify this in multiple ways, for example by hitting Ctrl+D, by typing exit and hitting Enter or by opening another terminal instance and running:

pkill -15 -x ssh

As you can see, terminating the ssh instance by any mean will let the command substitution finish its execution, finally letting the echo command run on its output, which in this case is nothing.

5
  • but here irrespective of the first echo the result is same Sep 9, 2015 at 6:45
  • @RamanaReddy I'm not sure what you mean
    – kos
    Sep 9, 2015 at 6:47
  • @RamanaReddy I've changed the example, see if this one makes more sense
    – kos
    Sep 9, 2015 at 7:06
  • @adonis Done, now it's explicit
    – kos
    Sep 9, 2015 at 11:50
  • 1
    I don't think you need to kill it. Pressing Ctrl-D, or, typing exit and pressing Enter, etc., should be enough.
    – muru
    Sep 24, 2015 at 5:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .