unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Artyom Poptsov <poptsov.artyom@gmail.com>
To: guile-user@gnu.org
Subject: Re: Using guile-ssh
Date: Mon, 18 Aug 2014 00:25:01 +0400	[thread overview]
Message-ID: <878ummx3s2.fsf@elephant.savannah> (raw)
In-Reply-To: <mailman.81.1408291224.11683.guile-user@gnu.org> (guile-user-request@gnu.org's message of "Sun, 17 Aug 2014 12:00:24 -0400")

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 <poptsov.artyom@gmail.com>
Home page: http://poptsov-artyom.narod.ru/



       reply	other threads:[~2014-08-17 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.81.1408291224.11683.guile-user@gnu.org>
2014-08-17 20:25 ` Artyom Poptsov [this message]
2014-08-15 16:44 Using guile-ssh R Sidhu
2014-08-16 12:12 ` Taylan Ulrich Bayirli/Kammer
2014-08-17 10:49   ` R Sidhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878ummx3s2.fsf@elephant.savannah \
    --to=poptsov.artyom@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).