guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using guile-ssh


From: Artyom Poptsov
Subject: Re: Using guile-ssh
Date: Mon, 18 Aug 2014 00:25:01 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi sidhu1f,

sorry, I overlooked your previous mails on Guile-SSH.  Glad to see that
Taylan helped you with some of the questions.  Thanks, Taylan.

> Re file transfer, I could cook up something of my own, unless someone
> already has working code?

Guile-SSH 0.6 represents channels as Guile ports, so you can use
standard Guile I/O procedures [1] to transfer data through channels (as
Taylan rightly pointed out).

Here is one of the possible implementations of file transferring:
  https://gist.github.com/artyom-poptsov/dfa428b1e6baa4030f00

I made it quickly and the code might be a bit ugly, but nevertheless it
should give you an idea how to use Guile-SSH channels for transferring
of data.  The example was tested with Guile-SSH 0.6 and libssh 0.5.5.
It works as follows:

  - The client sends file name to the server, then reads the given file
    line-by-line in the plain text mode and sends it to the server too.

  - The server reads file name from the channel, then reads the file
    contents and writes the received file to the same path as the
    original file.

On the server:

--8<---------------cut here---------------start------------->8---
$ ./server.scm -r ~/src/projects/guile-ssh/tests/rsakey  \
  -d ~/src/projects/guile-ssh/tests/dsakey -p 12345
--8<---------------cut here---------------end--------------->8---

Note that I used test SSH keys that come with Guile-SSH.  Your path to
these keys may differ from mine.

On the client:

--8<---------------cut here---------------start------------->8---
$ ./client.scm -i ~/src/projects/guile-ssh/tests/rsakey \
  -p 12345 127.0.0.1 /tmp/test-file
--8<---------------cut here---------------end--------------->8---

Replace 127.0.0.1 with IP address of your server.

Also take a look on the `examples' directory in the repo -- it contains
working examples of Guile-SSH usage.

Hope this helps,

- Artyom

[1] 
https://www.gnu.org/software/guile/manual/html_node/Input-and-Output.html#Input-and-Output

-- 
Artyom V. Poptsov <address@hidden>
Home page: http://poptsov-artyom.narod.ru/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]