Closed davexunit closed 6 years ago
Hi,
thanks for reporting. I'm investigating the problem; meanwhile you could use channel-get-exit-status
from (ssh channel)
as a workaround to check whether the command execution was successful or not. For example:
(let ((channel (open-remote-input-pipe session "uname -o")))
(if (zero? (channel-get-exit-status channel))
(write-line (read-line channel))
(write-line (string-append "ERROR: " (read-line channel))
(current-error-port))))
-- Artyom
In my case, the command is successful, it just happens to have output written to stderr.
Hello David,
the bug should be fixed now in 71a6e1e on the master branch, please check if it works for you.
Thanks!
-- Artyom
Hello,
here's an example of error handling:
(use-modules (ice-9 rdelim)
(ssh channel)
(ssh session)
(ssh auth)
(ssh popen))
(let ((session (make-session #:host "localhost")))
(connect! session)
(userauth-agent! session)
(let ((channel (open-remote-input-pipe* session "uname" "--badfood")))
(if (zero? (channel-get-exit-status channel))
(write-line (read-line channel))
(begin
(channel-set-stream! channel 'stderr)
(format #t "ERROR: ~a~%" (read-line channel))))))
Also there's a more generic solution committed in 2ab0287 on the 'master' branch; now it's possible to explicitly ask a server for a pseudo terminal to run commands such as top
(although when PTY is used the server merges stderr and stdout.) See the latest (guile-ssh) Remote Pipes
documentation for details.
-- Artyom
I'm closing the issue as the bug was fixed long ago.
-- Artyom
When reading text over a remote pipe, the input text I am reading contains both the text written to standard output as well as standard input. I noticed this because I messed up my .bashrc and referenced a function I did not have defined, which caused bash to write to stderr.
The code I'm using is this:
I would expect this to print "GNU/Linux", but instead it prints something like "home/dave/.bashrc: line 50: foo: command not found". The OpenSSH command-line client does not have this issue.