[plt-scheme] Re: ssh/sftp library in mzscheme

From: Jaime Vargas (jev at mac.com)
Date: Wed Mar 5 10:16:03 EST 2008

It will be nice to have planet module that supports to libssh.
However, Eli's recommendation of using a subprocess works.
Yesterday, I tried the below quick-and-dirty code using v4.
I have two questions:

1. Process doesn't allocate a tty, so the code below only works if  
you have a public key.
Is there a way to force a tty?

2. What is the best way start reading the response, using sleep is  
obviously ugly?

-- Jaime

#lang scheme

(require scheme/system)

(define (ssh host)
   (define-values (in out pid err proc-ctrl)
     (apply values (process (string-append "ssh -t " host))))
   (define buffer (make-bytes (expt 2 15)))
   (λ (cmd)
     (display cmd out)
     (newline out)
     (flush-output out)
     (sleep 2) 				; Ugly but it works
     (let loop ([result ""])
       (define bytes-read (read-bytes-avail!* buffer in))
       (if (> bytes-read 0)
           (loop (string-append result (bytes->string/utf-8 (subbytes  
buffer 0 bytes-read))))
           result))))

(define bruce-channel (ssh "bruce"))
(define result (bruce-channel "ls -l"))
(display result)


On Mar 3, 2008, at 12:48 PM, joe wrote:

> Yvan,
>
> I'm very new to mzscheme, but I have created a binding between Lua and
> a different ssh/sftp library (http://0xbadc0de.be/wiki/libssh:libssh).
>
> Unless you've heard of anyone else making progress on something like
> this I will see if I can produce a suitable binding for mzscheme. Drop
> me an email if you're still interested.
>
> -joe
>
> On Feb 14, 10:58 am, "Yvan Godin" <yvan.go... at gmail.com> wrote:
>> Hello Schemers
>>
>> For a little projet I need  an access to a ssh/sftp library
>> Erlang provide one but I will prefer  use mzscheme ;-)
>>
>> Do you know if something already exist for mzscheme ?
>> (may be a binding to libshh2http://sourceforge.net/projects/libssh2)
>>
>> thank's (and sorry for my bad english)
>>
>> Yvan
>>
>> _________________________________________________
>>   For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080305/41fa76c4/attachment.html>

Posted on the users mailing list.