diff options
| author | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2015-02-12 07:10:24 +0300 |
|---|---|---|
| committer | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2015-02-12 07:10:24 +0300 |
| commit | dd69590e51cb7e9210658cc108ffe865d8c93cbc (patch) | |
| tree | 46423347a6b59b7aebd5861aec4567b868f15c10 | |
| parent | channel-func.c (guile_ssh_channel_request_send_exit_status): Update docstring (diff) | |
| download | guile-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.
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | NEWS | 6 | ||||
| -rw-r--r-- | examples/sssh.scm.in | 23 | ||||
| -rw-r--r-- | examples/ssshd.scm.in | 5 |
4 files changed, 32 insertions, 8 deletions
@@ -1,3 +1,9 @@ +2015-02-12 Artyom Poptsov <poptsov.artyom@gmail.com> + + * examples/ssshd.scm.in (handle-request-exec): Send exit status. + * examples/sssh.scm.in (main): Handle exit status. + * NEWS: Update. + 2015-02-09 Artyom Poptsov <poptsov.artyom@gmail.com> * doc/api-channels.texi (Channels): Update description of @@ -17,6 +17,12 @@ Copyright (C) Artyom V. Poptsov <poptsov.artyom@gmail.com> ** New `channel-request-send-exit-status' procedure in (ssh channel) The procedure can be used to send the exit status to a client. ** Improve printing of Guile-SSH server objects +** Update examples +*** sssh + - Check exit status of an executed command. +*** ssshd + - Send exit status to the client according to the result of command + execution. ** Update documentation - Add description of the new procedures. 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) |
