"read" from terminal in the remote ssh script

"read" from terminal in the remote ssh script

am 04.12.2007 09:58:16 von Yakov

I feed a script to ssh to be executed on the other host,
literally like this:
cat script | ssh HOST bash
I need to ask operator questions in the script.

I tried several possibilities, nothing worked so far. The demo:

1.
echo 'echo AAA; read XXX' | ssh localhost bash
# -- doesnt work, stdin is redirected to the script itself
2.
echo 'echo AAA; read XXX # bash: line 1: /dev/tty: No such device or address
3.
echo 'echo AAA; read XXX <&1' | ssh localhost bash
# doesn't work, no waiting for the question
4.
echo 'echo AAA; read XXX <&2' | ssh localhost bash

Any solution ? I am especially suprised that #3 and #4
didn't work.

Yakov

Re: "read" from terminal in the remote ssh script

am 05.12.2007 03:57:31 von spcecdt

In article ,
Yakov wrote:
>I feed a script to ssh to be executed on the other host,
>literally like this:
> cat script | ssh HOST bash
>I need to ask operator questions in the script.
>
>I tried several possibilities, nothing worked so far. The demo:
>
>1.
> echo 'echo AAA; read XXX' | ssh localhost bash
> # -- doesnt work, stdin is redirected to the script itself
>2.
> echo 'echo AAA; read XXX > # bash: line 1: /dev/tty: No such device or address
>3.
> echo 'echo AAA; read XXX <&1' | ssh localhost bash
> # doesn't work, no waiting for the question
>4.
> echo 'echo AAA; read XXX <&2' | ssh localhost bash
>
>Any solution ? I am especially suprised that #3 and #4
>didn't work.

The obvious one is:

ssh localhost bash -c 'echo AAA; read XXX'

You could presumably make it work the way you want (feeding a script in)
in a sort of messy way by playing with port forwarding and e.g. netcat.

John
--
John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/