Skip to content

Instantly share code, notes, and snippets.

@artyom-poptsov
Created December 4, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artyom-poptsov/bfdf3acb5cc453c14cd5 to your computer and use it in GitHub Desktop.
Save artyom-poptsov/bfdf3acb5cc453c14cd5 to your computer and use it in GitHub Desktop.
Remote pipes example.
#!/usr/bin/guile \
-e main -s
!#
;;; open-remote-pipe.scm
;; Copyright (C) 2015 Artyom V. Poptsov <poptsov.artyom@gmail.com>
;;
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; The program is known to work with 'master' branch of Guile-SSH,
;; commit '4231315'.
;;; Code:
(use-modules (ice-9 rdelim)
;; Guile-SSH
(ssh session)
(ssh channel)
(ssh auth))
;;; Entry point
(define (main args)
(let ((s (make-session #:host "example.org" #:config #t)))
(connect! s)
(authenticate-server s)
(userauth-agent! s)
(let ((p (open-remote-pipe* s "top" "-u avp")))
(let r ((line (read-line p)))
(unless (eof-object? line)
(write-line line)
(r (read-line p)))))))
;;; open-remote-pipe.scm ends here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment