summaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/apiv1-exec.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-03-09 17:19:50 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-03-09 17:19:50 +0100
commit17812a0a4388ab0c87084ef7e8118d87e8fadcf7 (patch)
treefafa3e95348087028e27a0b13ee02bd5aa734fd6 /lib/xdsserver/apiv1-exec.go
parent65e09e831cf13343ac713fbf15281174d1f13a94 (diff)
Fixed terminal output (support escape and control characters)
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsserver/apiv1-exec.go')
-rw-r--r--lib/xdsserver/apiv1-exec.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/xdsserver/apiv1-exec.go b/lib/xdsserver/apiv1-exec.go
index 327c4c5..57ea1f1 100644
--- a/lib/xdsserver/apiv1-exec.go
+++ b/lib/xdsserver/apiv1-exec.go
@@ -152,14 +152,17 @@ func (s *APIService) execCmd(c *gin.Context) {
// Define callback for input (stdin)
execWS.InputEvent = xsapiv1.ExecInEvent
- execWS.InputCB = func(e *eows.ExecOverWS, stdin string) (string, error) {
+ execWS.InputCB = func(e *eows.ExecOverWS, bStdin []byte) ([]byte, error) {
+
+ stdin := string(bStdin)
+
s.Log.Debugf("STDIN <<%v>>", strings.Replace(stdin, "\n", "\\n", -1))
// Handle Ctrl-D
if len(stdin) == 1 && stdin == "\x04" {
// Close stdin
errMsg := fmt.Errorf("close stdin: %v", stdin)
- return "", errMsg
+ return []byte{}, errMsg
}
// Set correct path
@@ -172,12 +175,15 @@ func (s *APIService) execCmd(c *gin.Context) {
// Translate paths from client to server
stdin = (*f).ConvPathCli2Svr(stdin)
}
-
- return stdin, nil
+ return []byte(stdin), nil
}
// Define callback for output (stdout+stderr)
- execWS.OutputCB = func(e *eows.ExecOverWS, stdout, stderr string) {
+ execWS.OutputCB = func(e *eows.ExecOverWS, bStdout, bStderr []byte) {
+
+ stdout := string(bStdout)
+ stderr := string(bStderr)
+
// IO socket can be nil when disconnected
so := s.sessions.IOSocketGet(e.Sid)
if so == nil {