emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Connect to the ssh and execute any command
@ 2013-09-12 21:56 Andrey Tykhonov
  2013-09-12 22:16 ` Eduardo Ochs
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Andrey Tykhonov @ 2013-09-12 21:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi all!

During last several days I was trying to implement quite simple script
which:

1. Creates new buffer with the shell (M-x shell)
2. Executes there "ssh username@domain.com". As result -- the password
prompt appears in the minibuffer. I manually input password.
3. Then script executes any command in the recently created buffer
(shell), for example: "ls -la". So I expect to see directory listing on
the domain.com.

but, for sorry, I cannot to do so that "ls -la" will be executed!

I googled, I have tried many different approaches but without any luck :-(

Here I should mention quite important thing: I cannot use TRAMP because
it does not work with the server to which the script connects and then
on which executes "ls -la". (I suppose that TRAMP uses FUSE, but for
sorry FUSE does not work with mine server). So TRAMP is not available
for me.

For example I tried:

(progn
  (make-comint-in-buffer "ssh" "*ssh*" "ssh" nil "username@domain.com")
  (make-comint-in-buffer "ls" "*ssh*" "ls" nil "-la")
)
"ls -la" does not executes.

(progn
  (make-comint-in-buffer "ssh" "*ssh*" "ssh" nil "username@domain.com")
  ; instead of "ls -la" here is pwd
  (start-file-process "pwd" "*ssh*" "pwd")
) 
In *scratch* outputs just "Process pwd finished"

(progn
  (start-process-shell-command "ssh" "*ssh*" "ssh usernamev@domain.com")
  (process-send-string (get-buffer-process "*ssh*") "pwd\n")
)
Seems this one -- is overall wrong approach because start-process-shell-command
does not want to show shell after I put the password in the prompt.

Also I tried call-process instead of start-process-shell-command:
(call-process "ssh" nil "*ssh*" t "username@domain.com")

I got "Pseudo-terminal will not be allocated because stdin is not a
terminal".

Then...

(progn
  (setq buffer (get-buffer-create "*ssh*"))
  ; switch to buffer
  (switch-to-buffer-other-window buffer)
  ; execute there a shell
  (shell buffer)
  ; then executes there mine commands
  (process-send-string (get-buffer-process "*ssh*") "ssh username@domain.com")
  (comint-send-input)
  ; and
  (process-send-string (get-buffer-process "*ssh*") "ls -la")
  (comint-send-input)
)
Last process-send-string does not execute in time because it is not synchronous.
Last process-send-string does not wait for previous...

Also I tried set-process-filter but filter just eats password prompt so
I could not input password....


How my task could be implemented without TRAMP?

Please help!



Regards,
Andrey

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

* Re: Connect to the ssh and execute any command
  2013-09-12 21:56 Connect to the ssh and execute any command Andrey Tykhonov
@ 2013-09-12 22:16 ` Eduardo Ochs
  2013-09-12 22:38 ` Eric Schulte
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Eduardo Ochs @ 2013-09-12 22:16 UTC (permalink / raw)
  To: Andrey Tykhonov; +Cc: Org Mode

[-- Attachment #1: Type: text/plain, Size: 3623 bytes --]

Hi Andrey,

you can use eev - take a look at the demo that starts at 0:18 in this
video here:

  http://www.youtube.com/watch?v=Lj_zKC5BR64
  http://angg.twu.net/eev-videos/video4-eepitch.mp4

There are many things that I do in the server that hosts my home page
by using this to set up a connection,

  (eepitch-do "ssh edrx@angg.twu.net")

and then typing <f8> on each line that needs to be sent.

If you have any difficulty in setting things up feel free to get in
touch by e-mail, IRC (#eev at Freenode) or gmail chat - there are some
new features that do not appear in videos yet (the videos I have are a
few months old), and I am just resurecting my screencast-making
scripts to make some new ones... and I am exactly at the point where
tests and feedback can clarify a lot my ideas about the best ways to
present things.

  Cheers! =)
    Eduardo Ochs
    eduardoochs@gmail.com
    http://angg.twu.net/



On Thu, Sep 12, 2013 at 6:56 PM, Andrey Tykhonov <atykhonov@gmail.com>wrote:

> Hi all!
>
> During last several days I was trying to implement quite simple script
> which:
>
> 1. Creates new buffer with the shell (M-x shell)
> 2. Executes there "ssh username@domain.com". As result -- the password
> prompt appears in the minibuffer. I manually input password.
> 3. Then script executes any command in the recently created buffer
> (shell), for example: "ls -la". So I expect to see directory listing on
> the domain.com.
>
> but, for sorry, I cannot to do so that "ls -la" will be executed!
>
> I googled, I have tried many different approaches but without any luck :-(
>
> Here I should mention quite important thing: I cannot use TRAMP because
> it does not work with the server to which the script connects and then
> on which executes "ls -la". (I suppose that TRAMP uses FUSE, but for
> sorry FUSE does not work with mine server). So TRAMP is not available
> for me.
>
> For example I tried:
>
> (progn
>   (make-comint-in-buffer "ssh" "*ssh*" "ssh" nil "username@domain.com")
>   (make-comint-in-buffer "ls" "*ssh*" "ls" nil "-la")
> )
> "ls -la" does not executes.
>
> (progn
>   (make-comint-in-buffer "ssh" "*ssh*" "ssh" nil "username@domain.com")
>   ; instead of "ls -la" here is pwd
>   (start-file-process "pwd" "*ssh*" "pwd")
> )
> In *scratch* outputs just "Process pwd finished"
>
> (progn
>   (start-process-shell-command "ssh" "*ssh*" "ssh usernamev@domain.com")
>   (process-send-string (get-buffer-process "*ssh*") "pwd\n")
> )
> Seems this one -- is overall wrong approach because
> start-process-shell-command
> does not want to show shell after I put the password in the prompt.
>
> Also I tried call-process instead of start-process-shell-command:
> (call-process "ssh" nil "*ssh*" t "username@domain.com")
>
> I got "Pseudo-terminal will not be allocated because stdin is not a
> terminal".
>
> Then...
>
> (progn
>   (setq buffer (get-buffer-create "*ssh*"))
>   ; switch to buffer
>   (switch-to-buffer-other-window buffer)
>   ; execute there a shell
>   (shell buffer)
>   ; then executes there mine commands
>   (process-send-string (get-buffer-process "*ssh*") "ssh
> username@domain.com")
>   (comint-send-input)
>   ; and
>   (process-send-string (get-buffer-process "*ssh*") "ls -la")
>   (comint-send-input)
> )
> Last process-send-string does not execute in time because it is not
> synchronous.
> Last process-send-string does not wait for previous...
>
> Also I tried set-process-filter but filter just eats password prompt so
> I could not input password....
>
>
> How my task could be implemented without TRAMP?
>
> Please help!
>
>
>
> Regards,
> Andrey
>
>
>
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 5433 bytes --]

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

* Re: Connect to the ssh and execute any command
  2013-09-12 21:56 Connect to the ssh and execute any command Andrey Tykhonov
  2013-09-12 22:16 ` Eduardo Ochs
@ 2013-09-12 22:38 ` Eric Schulte
  2013-09-13  6:45 ` Michael Albinus
  2013-09-13 11:23 ` Suvayu Ali
  3 siblings, 0 replies; 9+ messages in thread
From: Eric Schulte @ 2013-09-12 22:38 UTC (permalink / raw)
  To: Andrey Tykhonov; +Cc: emacs-orgmode

If you want an Org-mode solution, you could do the following.

    #+begin_src sh :dir /ssh:username@domain.org:
      ls -la
    #+end_src

Andrey Tykhonov <atykhonov@gmail.com> writes:

> Hi all!
>
> During last several days I was trying to implement quite simple script
> which:
>
> 1. Creates new buffer with the shell (M-x shell)
> 2. Executes there "ssh username@domain.com". As result -- the password
> prompt appears in the minibuffer. I manually input password.
> 3. Then script executes any command in the recently created buffer
> (shell), for example: "ls -la". So I expect to see directory listing on
> the domain.com.
>
> but, for sorry, I cannot to do so that "ls -la" will be executed!
>
> I googled, I have tried many different approaches but without any luck :-(
>
> Here I should mention quite important thing: I cannot use TRAMP because
> it does not work with the server to which the script connects and then
> on which executes "ls -la". (I suppose that TRAMP uses FUSE, but for
> sorry FUSE does not work with mine server). So TRAMP is not available
> for me.
>
> For example I tried:
>
> (progn
>   (make-comint-in-buffer "ssh" "*ssh*" "ssh" nil "username@domain.com")
>   (make-comint-in-buffer "ls" "*ssh*" "ls" nil "-la")
> )
> "ls -la" does not executes.
>
> (progn
>   (make-comint-in-buffer "ssh" "*ssh*" "ssh" nil "username@domain.com")
>   ; instead of "ls -la" here is pwd
>   (start-file-process "pwd" "*ssh*" "pwd")
> ) 
> In *scratch* outputs just "Process pwd finished"
>
> (progn
>   (start-process-shell-command "ssh" "*ssh*" "ssh usernamev@domain.com")
>   (process-send-string (get-buffer-process "*ssh*") "pwd\n")
> )
> Seems this one -- is overall wrong approach because start-process-shell-command
> does not want to show shell after I put the password in the prompt.
>
> Also I tried call-process instead of start-process-shell-command:
> (call-process "ssh" nil "*ssh*" t "username@domain.com")
>
> I got "Pseudo-terminal will not be allocated because stdin is not a
> terminal".
>
> Then...
>
> (progn
>   (setq buffer (get-buffer-create "*ssh*"))
>   ; switch to buffer
>   (switch-to-buffer-other-window buffer)
>   ; execute there a shell
>   (shell buffer)
>   ; then executes there mine commands
>   (process-send-string (get-buffer-process "*ssh*") "ssh username@domain.com")
>   (comint-send-input)
>   ; and
>   (process-send-string (get-buffer-process "*ssh*") "ls -la")
>   (comint-send-input)
> )
> Last process-send-string does not execute in time because it is not synchronous.
> Last process-send-string does not wait for previous...
>
> Also I tried set-process-filter but filter just eats password prompt so
> I could not input password....
>
>
> How my task could be implemented without TRAMP?
>
> Please help!
>
>
>
> Regards,
> Andrey
>
>
>
>
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

* Re: Connect to the ssh and execute any command
  2013-09-12 21:56 Connect to the ssh and execute any command Andrey Tykhonov
  2013-09-12 22:16 ` Eduardo Ochs
  2013-09-12 22:38 ` Eric Schulte
@ 2013-09-13  6:45 ` Michael Albinus
  2013-09-16 17:44   ` Andrey Tykhonov
  2013-09-13 11:23 ` Suvayu Ali
  3 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2013-09-13  6:45 UTC (permalink / raw)
  To: Andrey Tykhonov; +Cc: tramp-devel, emacs-orgmode

Andrey Tykhonov <atykhonov@gmail.com> writes:

[Cc to tramp-devel@gnu.org, because I want to help with Tramp config]

> Hi all!

Hi Andrey,

> During last several days I was trying to implement quite simple script
> which:
>
> 1. Creates new buffer with the shell (M-x shell)
> 2. Executes there "ssh username@domain.com". As result -- the password
> prompt appears in the minibuffer. I manually input password.
> 3. Then script executes any command in the recently created buffer
> (shell), for example: "ls -la". So I expect to see directory listing on
> the domain.com.
>
> but, for sorry, I cannot to do so that "ls -la" will be executed!
>
> I googled, I have tried many different approaches but without any luck :-(
>
> Here I should mention quite important thing: I cannot use TRAMP because
> it does not work with the server to which the script connects and then
> on which executes "ls -la". (I suppose that TRAMP uses FUSE, but for
> sorry FUSE does not work with mine server). So TRAMP is not available
> for me.

Tramp does not use FUSE for ssh connections. Please show an example
connection to the remote host, and how it fails.

Prior to the test, you should apply

   (setq tramp-verbose 6)

This will create a Tramp debug buffer, which shall show the problem.

> Regards,
> Andrey

Best regards, Michael.

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

* Re: Connect to the ssh and execute any command
  2013-09-12 21:56 Connect to the ssh and execute any command Andrey Tykhonov
                   ` (2 preceding siblings ...)
  2013-09-13  6:45 ` Michael Albinus
@ 2013-09-13 11:23 ` Suvayu Ali
  3 siblings, 0 replies; 9+ messages in thread
From: Suvayu Ali @ 2013-09-13 11:23 UTC (permalink / raw)
  To: emacs-orgmode

Hi Andrey,

I think you will have better luck on the <help-gnu-emacs@gnu.org> list.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: Connect to the ssh and execute any command
  2013-09-13  6:45 ` Michael Albinus
@ 2013-09-16 17:44   ` Andrey Tykhonov
  2013-09-17  6:54     ` Michael Albinus
  0 siblings, 1 reply; 9+ messages in thread
From: Andrey Tykhonov @ 2013-09-16 17:44 UTC (permalink / raw)
  To: Michael Albinus; +Cc: tramp-devel, emacs-orgmode

On Fri, Sep 13, 2013 at 08:45:02AM +0200, Michael Albinus wrote:
> Andrey Tykhonov <atykhonov@gmail.com> writes:
> 
> [Cc to tramp-devel@gnu.org, because I want to help with Tramp config]
> 
> > Hi all!
> 
> Hi Andrey,
> 
> > During last several days I was trying to implement quite simple script
> > which:
> >
> > 1. Creates new buffer with the shell (M-x shell)
> > 2. Executes there "ssh username@domain.com". As result -- the password
> > prompt appears in the minibuffer. I manually input password.
> > 3. Then script executes any command in the recently created buffer
> > (shell), for example: "ls -la". So I expect to see directory listing on
> > the domain.com.
> >
> > but, for sorry, I cannot to do so that "ls -la" will be executed!
> >
> > I googled, I have tried many different approaches but without any luck :-(
> >
> > Here I should mention quite important thing: I cannot use TRAMP because
> > it does not work with the server to which the script connects and then
> > on which executes "ls -la". (I suppose that TRAMP uses FUSE, but for
> > sorry FUSE does not work with mine server). So TRAMP is not available
> > for me.
> 
> Tramp does not use FUSE for ssh connections. Please show an example
> connection to the remote host, and how it fails.

First of all I added

    (setq tramp-verbose 6)

to the ~/.emacs

Then M-x eshell, and then

    cd /ssh:username@hostname:/some/existing/dir

I get password prompt, I put correct password, then get such prompt:

    /ssh:username@hostname:/some/existing/dir $

Here I try to "ls -la" and get the following error:

    Couldn't find a POSIX `id' command



Best regards,
Andrey.

> 
> Prior to the test, you should apply
> 
>    (setq tramp-verbose 6)
> 
> This will create a Tramp debug buffer, which shall show the problem.
> 
> > Regards,
> > Andrey
> 
> Best regards, Michael.

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

* Re: Connect to the ssh and execute any command
  2013-09-16 17:44   ` Andrey Tykhonov
@ 2013-09-17  6:54     ` Michael Albinus
  2013-09-17 19:05       ` Andrey Tykhonov
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2013-09-17  6:54 UTC (permalink / raw)
  To: Andrey Tykhonov; +Cc: tramp-devel, emacs-orgmode

Andrey Tykhonov <atykhonov@gmail.com> writes:

Hi Andrey,

>> Tramp does not use FUSE for ssh connections. Please show an example
>> connection to the remote host, and how it fails.

> Here I try to "ls -la" and get the following error:
>
>     Couldn't find a POSIX `id' command

Your remote host does not find a proper "id" command. What happens, if
you call the following commands in a shell on that remote host:

# id -u
# id --version
# which id
# whereis id
# uname -a

> Best regards,
> Andrey.

Best regards, Michael.

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

* Re: Connect to the ssh and execute any command
  2013-09-17  6:54     ` Michael Albinus
@ 2013-09-17 19:05       ` Andrey Tykhonov
  2013-09-18  6:42         ` Michael Albinus
  0 siblings, 1 reply; 9+ messages in thread
From: Andrey Tykhonov @ 2013-09-17 19:05 UTC (permalink / raw)
  To: Michael Albinus; +Cc: tramp-devel, emacs-orgmode

On Tue, Sep 17, 2013 at 08:54:51AM +0200, Michael Albinus wrote:
> Andrey Tykhonov <atykhonov@gmail.com> writes:
> 
> Hi Andrey,

Hi Michael!

> 
> >> Tramp does not use FUSE for ssh connections. Please show an example
> >> connection to the remote host, and how it fails.
> 
> > Here I try to "ls -la" and get the following error:
> >
> >     Couldn't find a POSIX `id' command
> 
> Your remote host does not find a proper "id" command. What happens, if
> you call the following commands in a shell on that remote host:
> 
> # id -u

id: Command not found.

> # id --version

id: Command not found.

> # which id

id: Command not found.

> # whereis id

whereis: Command not found.

I also didn't find 'id' by means of

find / -name id

As I understand TRAMP is not able to work without 'id'. Therefore TRAMP is
not suitable for me...

> # uname -a

FreeBSD {hostname} 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Sep 13
21:22:42 PDT 2013 auto-build@{hostname}:{some/path/} amd64

Here I replaced real hostname by {hostname}.



Best regards,
Andrey


> 
> > Best regards,
> > Andrey.
> 
> Best regards, Michael.

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

* Re: Connect to the ssh and execute any command
  2013-09-17 19:05       ` Andrey Tykhonov
@ 2013-09-18  6:42         ` Michael Albinus
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Albinus @ 2013-09-18  6:42 UTC (permalink / raw)
  To: Andrey Tykhonov; +Cc: tramp-devel, emacs-orgmode

Andrey Tykhonov <atykhonov@gmail.com> writes:

> Hi Michael!

Hi Andrey,

>> Your remote host does not find a proper "id" command. What happens, if
>> you call the following commands in a shell on that remote host:
>> 
>> # id -u
>
> id: Command not found.
>
>> # whereis id
>
> whereis: Command not found.
>
> I also didn't find 'id' by means of
>
> find / -name id
>
> As I understand TRAMP is not able to work without 'id'. Therefore TRAMP is
> not suitable for me...
>
>> # uname -a
>
> FreeBSD {hostname} 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Sep 13
> 21:22:42 PDT 2013 auto-build@{hostname}:{some/path/} amd64

Strange. `id' (and also `whereis') belong to FreeBSD proper. See for
example <http://www.freebsd.org/cgi/man.cgi?query=id&amp;sektion=1>

You might check with your remote host why it is not installed.

> Best regards,
> Andrey

Best regards, Michael.

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

end of thread, other threads:[~2013-09-18  6:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-12 21:56 Connect to the ssh and execute any command Andrey Tykhonov
2013-09-12 22:16 ` Eduardo Ochs
2013-09-12 22:38 ` Eric Schulte
2013-09-13  6:45 ` Michael Albinus
2013-09-16 17:44   ` Andrey Tykhonov
2013-09-17  6:54     ` Michael Albinus
2013-09-17 19:05       ` Andrey Tykhonov
2013-09-18  6:42         ` Michael Albinus
2013-09-13 11:23 ` Suvayu Ali

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).