From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eduardo Ochs Subject: Re: Connect to the ssh and execute any command Date: Thu, 12 Sep 2013 19:16:36 -0300 Message-ID: References: <20130912215641.GA6461@demi> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0443041a57e26f04e6371798 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKFBq-0006U9-L7 for emacs-orgmode@gnu.org; Thu, 12 Sep 2013 18:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKFBp-0002x4-5e for emacs-orgmode@gnu.org; Thu, 12 Sep 2013 18:16:42 -0400 Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:42664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKFBo-0002wc-5S for emacs-orgmode@gnu.org; Thu, 12 Sep 2013 18:16:41 -0400 Received: by mail-we0-f173.google.com with SMTP id w62so404529wes.18 for ; Thu, 12 Sep 2013 15:16:37 -0700 (PDT) In-Reply-To: <20130912215641.GA6461@demi> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andrey Tykhonov Cc: Org Mode --f46d0443041a57e26f04e6371798 Content-Type: text/plain; charset=ISO-8859-1 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 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 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 > > > > > > > --f46d0443041a57e26f04e6371798 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Andrey,

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


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

=A0 (ee= pitch-do "ssh edrx@angg.twu.net")


If you have any difficulty in setting things up feel fr= ee to get in
touch by e-mail, IRC (#eev at Freenode) or gmail cha= t - 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
<= div>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 t= o
present things.

=A0 Cheers! =3D)
= =A0 =A0 Eduardo Ochs



On Thu, Sep 12, 2013 at 6:56 PM, Andrey Tykhonov = <atykhonov@gmai= l.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 list= ing 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 :-(<= br>
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
=A0 (make-comint-in-buffer "ssh" "*ssh*" "ssh"= ; nil "username@domain.com&= quot;)
=A0 (make-comint-in-buffer "ls" "*ssh*" "ls" = nil "-la")
)
"ls -la" does not executes.

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

(progn
=A0 (start-process-shell-command "ssh" "*ssh*" "ss= h usernamev@domain.com") =A0 (process-send-string (get-buffer-process "*ssh*") "pwd\n= ")
)
Seems this one -- is overall wrong approach because start-process-shell-com= mand
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
=A0 (setq buffer (get-buffer-create "*ssh*"))
=A0 ; switch to buffer
=A0 (switch-to-buffer-other-window buffer)
=A0 ; execute there a shell
=A0 (shell buffer)
=A0 ; then executes there mine commands
=A0 (process-send-string (get-buffer-process "*ssh*") "ssh <= a href=3D"mailto:username@domain.com">username@domain.com")
=A0 (comint-send-input)
=A0 ; and
=A0 (process-send-string (get-buffer-process "*ssh*") "ls -l= a")
=A0 (comint-send-input)
)
Last process-send-string does not execute in time because it is not synchro= nous.
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







--f46d0443041a57e26f04e6371798--