summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2015-02-12 07:10:24 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2015-02-12 07:10:24 +0300
commitdd69590e51cb7e9210658cc108ffe865d8c93cbc (patch)
tree46423347a6b59b7aebd5861aec4567b868f15c10 /examples
parentchannel-func.c (guile_ssh_channel_request_send_exit_status): Update docstring (diff)
downloadguile-ssh-dd69590e51cb7e9210658cc108ffe865d8c93cbc.tar.gz
examples/sssh{,d}.scm.in: Handle exit status
* examples/ssshd.scm.in (handle-request-exec): Send exit status. * examples/sssh.scm.in (main): Handle exit status. * NEWS: Update.
Diffstat (limited to 'examples')
-rw-r--r--examples/sssh.scm.in23
-rw-r--r--examples/ssshd.scm.in5
2 files changed, 20 insertions, 8 deletions
diff --git a/examples/sssh.scm.in b/examples/sssh.scm.in
index 6894a70..bb1f79e 100644
--- a/examples/sssh.scm.in
+++ b/examples/sssh.scm.in
@@ -209,14 +209,21 @@ Options:
(print-debug "8. channel-request-exec (ssh_channel_request_exec)\n")
(channel-request-exec channel cmd)
- (print-debug "9. channel-poll (ssh_channel_poll)\n")
- (let poll ((ready? #f))
- (if ready?
- (begin
- (print-debug "10. channel-read (ssh_channel_read)\n")
- (display (read-all channel))
- (newline))
- (poll (char-ready? channel))))
+ (case (channel-get-exit-status channel)
+ ((0)
+ (print-debug "9. channel-poll (ssh_channel_poll)\n")
+ (let poll ((ready? #f))
+ (if ready?
+ (begin
+ (print-debug "10. channel-read (ssh_channel_read)\n")
+ (display (read-all channel))
+ (newline))
+ (poll (char-ready? channel)))))
+ (else =>
+ (lambda (status)
+ (format #t
+ "ERROR: Failed to execute command `~a' (exit status ~a)~%"
+ cmd status))))
(close channel)
(disconnect! session))))))
diff --git a/examples/ssshd.scm.in b/examples/ssshd.scm.in
index 0c595d7..ba52818 100644
--- a/examples/ssshd.scm.in
+++ b/examples/ssshd.scm.in
@@ -82,6 +82,11 @@
(format #t " cmd: ~a~%" cmd)
(let* ((port (open-input-pipe cmd))
(res (read-all port)))
+
+ (if (string-null? res)
+ (channel-request-send-exit-status channel 1)
+ (channel-request-send-exit-status channel 0))
+
(display res channel))))
(define (handle-req-auth session msg msg-type)