summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--doc/api-channels.texi17
-rw-r--r--modules/ssh/channel.scm26
3 files changed, 44 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 0f38913..5ba626f 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,8 @@ Copyright (C) Artyom V. Poptsov <poptsov.artyom@gmail.com>
*** New procedure 'node-server-running?' in (ssh dist node)
*** New procedure 'node-run-server' in (ssh dist node)
*** New procedure 'session-parse-config!' in (ssh session)
+*** New procedure 'open-remote-pipe' in (ssh channel)
+*** New procedure 'open-remote-pipe*' in (ssh channel)
** 'make-session' now takes 'config' option
that allows to specify whether the SSH config should be parsed or not, and
optionally the path to the config.
diff --git a/doc/api-channels.texi b/doc/api-channels.texi
index 71278d2..6123027 100644
--- a/doc/api-channels.texi
+++ b/doc/api-channels.texi
@@ -8,6 +8,7 @@
@menu
* Channel Management::
+* Remote Pipes::
* Port Forwarding::
* Tunnels::
@end menu
@@ -139,6 +140,22 @@ instruction). The @var{channel} must be open. Return the exist status, or
@code{guile-ssh-error} on error.
@end deffn
+@node Remote Pipes
+@subsection Remote Pipes
+@cindex Remote Pipes
+
+@deffn {Scheme Procedure} open-remote-pipe session command
+Execute a @var{command} on the remote host using a @var{session} with a pipe
+to it. The pipe works in both directions. Returns newly created port
+(channel).
+@end deffn
+
+@deffn {Scheme Procedure} open-remote-pipe* session prog [args...]
+Execute @var{prog} on the remote host with the given @var{args} using a
+@var{session} with a pipe to it. The pipe works in both directions. Returns
+newly created port (channel).
+@end deffn
+
@node Port Forwarding
@subsection Port Forwarding
diff --git a/modules/ssh/channel.scm b/modules/ssh/channel.scm
index ce35bd3..e65d946 100644
--- a/modules/ssh/channel.scm
+++ b/modules/ssh/channel.scm
@@ -66,7 +66,11 @@
channel-get-session
channel-get-exit-status
channel-open?
- channel-eof?))
+ channel-eof?
+
+ ;; High-level procedures.
+ open-remote-pipe
+ open-remote-pipe*))
(define* (channel-open-forward channel
@@ -104,6 +108,26 @@ issued."
(%channel-accept-forward session timeout))
+;;; High-level procedures.
+;; TODO: Add error handling.
+
+(define (open-remote-pipe session command)
+ "Execute a COMMAND on the remote host using a SESSION with a pipe to it.
+The pipe works in both directions. Returns newly created port (channel)."
+ (let ((channel (make-channel session)))
+ (channel-open-session channel)
+ (channel-request-pty channel)
+ (channel-request-exec channel command)
+ channel))
+
+(define (open-remote-pipe* session prog . args)
+ "Execute COMMANDS on the remote host using a SESSION with a pipe to it. The
+pipe works in both directions. Returns newly created port (channel)."
+ (open-remote-pipe session (string-join (cons prog args))))
+
+;;;
+
+
(load-extension "libguile-ssh" "init_channel")
;;; channel.scm ends here.