zsh-users
 help / color / mirror / code / Atom feed
* interactive shell with ssh
@ 2003-08-04 11:11 Andy Spiegl
  2003-08-04 15:36 ` [6433] " Danek Duvall
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Spiegl @ 2003-08-04 11:11 UTC (permalink / raw)
  To: ZSH User List

Hi,

I have to admin several remote machines.  Usually I just do a
 xterm -e ssh some.other.host
which works just great.

But now I want to setup a mechanism that executes commands on _all_ remote
machines, e.g "apt-get update; apt-get upgrade".  So I wrote a script that
loops through the list of hosts and calls:

 xterm -e ssh -l root $somehost "apt-get update; apt-get upgrade; echo 'Press ENTER to close'; read"

First this seemed to work great, but then I noticed that "apt-get upgrade"
failed sometimes because that PATH was set wrong so that it couldn't find
ldconfig for example.  I noticed that ssh sets some default path and zsh
doesn't modify that because it's not an interactive shell.  Doh.

After I found a solution to that (using zshenv) I next noticed that
"dialog" (which is used by the Debian install scripts to ask configuration
questions) doesn't work either because TERM is not set and because zsh
thinks there is no tty.  Now I'm stuck.  :-(

Is there any way to execute commands on remote hosts allowing user
interaction and everything - just as if I would first login with an
interactive shell and then execute these commands???

Thanks a lot for any pointer,
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Computers in the future may weigh no more than 1.5 tons.
  - Popular Mechanics, 1949


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [6433] interactive shell with ssh
  2003-08-04 11:11 interactive shell with ssh Andy Spiegl
@ 2003-08-04 15:36 ` Danek Duvall
  2003-08-04 15:42 ` Dan Nelson
  2003-08-04 16:30 ` Bart Schaefer
  2 siblings, 0 replies; 5+ messages in thread
From: Danek Duvall @ 2003-08-04 15:36 UTC (permalink / raw)
  To: ZSH User List

On Mon, Aug 04, 2003 at 01:11:48PM +0200, Andy Spiegl wrote:

>  xterm -e ssh -l root $somehost "apt-get update; apt-get upgrade; echo 'Press ENTER to close'; read"
> 
> After I found a solution to that (using zshenv) I next noticed that
> "dialog" doesn't work either because TERM is not set and because zsh
> thinks there is no tty.

Have you tried "ssh -t"?  That makes the remote end allocate a TTY (so
you can do "ssh -t vi", for instance), and it also sets the TERM
variable on the remote end.

Danek


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: interactive shell with ssh
  2003-08-04 11:11 interactive shell with ssh Andy Spiegl
  2003-08-04 15:36 ` [6433] " Danek Duvall
@ 2003-08-04 15:42 ` Dan Nelson
  2003-08-04 16:03   ` Andy Spiegl
  2003-08-04 16:30 ` Bart Schaefer
  2 siblings, 1 reply; 5+ messages in thread
From: Dan Nelson @ 2003-08-04 15:42 UTC (permalink / raw)
  To: ZSH User List

> After I found a solution to that (using zshenv) I next noticed that
> "dialog" (which is used by the Debian install scripts to ask
> configuration questions) doesn't work either because TERM is not set
> and because zsh thinks there is no tty.  Now I'm stuck.  :-(

That's because there is no tty; by default ssh does not allocate a tty
when you pass it a command to execute.  Run ssh -t to force a tty to be
created.

-- 
	Dan Nelson
	dnelson@allantgroup.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: interactive shell with ssh
  2003-08-04 15:42 ` Dan Nelson
@ 2003-08-04 16:03   ` Andy Spiegl
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Spiegl @ 2003-08-04 16:03 UTC (permalink / raw)
  To: ZSH User List

Dan Nelson wrote:
> That's because there is no tty; by default ssh does not allocate a tty
> when you pass it a command to execute.  Run ssh -t to force a tty to be
> created.

Thanks so much for that one!  Now it works like a charm.
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Horse sense is the thing a horse has which keeps it from
 betting on people.  -- W. C. Fields


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: interactive shell with ssh
  2003-08-04 11:11 interactive shell with ssh Andy Spiegl
  2003-08-04 15:36 ` [6433] " Danek Duvall
  2003-08-04 15:42 ` Dan Nelson
@ 2003-08-04 16:30 ` Bart Schaefer
  2 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2003-08-04 16:30 UTC (permalink / raw)
  To: ZSH User List

On Aug 4,  1:11pm, Andy Spiegl wrote:
}
} Is there any way to execute commands on remote hosts allowing user
} interaction and everything - just as if I would first login with an
} interactive shell and then execute these commands???

To expand somewhat on Dan Nelson's answer:

You can execute _one_ command on a remote host that way with

  ssh -e none -t remoteuser@remote.host "remotecommand ..."

If what you have is a whole series of commands to automate "as if" you
had typed them, you have the problem of needing to know exactly when a
user interaction will occur -- there aren't separate input streams for
commands vs. user input.

The closest you might get is to assemble a shell script file of the
commands to be executed, "scp" that to the remote host, then "ssh -t"
to the same host to run the script as the single remote command.  But
that introduces the need to be security conscious that the file you
execute is really the same one you scp'd.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-08-04 20:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-04 11:11 interactive shell with ssh Andy Spiegl
2003-08-04 15:36 ` [6433] " Danek Duvall
2003-08-04 15:42 ` Dan Nelson
2003-08-04 16:03   ` Andy Spiegl
2003-08-04 16:30 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).