cleaned up and maybe finished the guile lab tool
This commit is contained in:
parent
4290973048
commit
74142365eb
24 changed files with 895 additions and 20 deletions
24
packages/lab-tool/archive/core/ssh.scm
Normal file
24
packages/lab-tool/archive/core/ssh.scm
Normal file
|
@ -0,0 +1,24 @@
|
|||
;; lab/core/ssh.scm - SSH operations
|
||||
|
||||
(define-module (lab core ssh)
|
||||
#:use-module (ice-9 format)
|
||||
#:use-module (ice-9 popen)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (ice-9 textual-ports)
|
||||
#:export (test-ssh-connection
|
||||
run-remote-command))
|
||||
|
||||
(define (test-ssh-connection machine-name)
|
||||
"Test SSH connection to machine"
|
||||
(zero? (system (format #f "ssh -o ConnectTimeout=5 -o BatchMode=yes ~a exit 2>/dev/null" machine-name))))
|
||||
|
||||
(define (run-remote-command machine-name command . args)
|
||||
"Run command on remote machine via SSH"
|
||||
(let* ((full-command (if (null? args)
|
||||
command
|
||||
(string-join (cons command args) " ")))
|
||||
(ssh-command (format #f "ssh ~a '~a'" machine-name full-command))
|
||||
(port (open-input-pipe ssh-command))
|
||||
(output (read-string port))
|
||||
(status (close-pipe port)))
|
||||
(values (zero? status) output)))
|
Loading…
Add table
Add a link
Reference in a new issue