From 00571d80919270d23d565f6123963ad68e874af0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 10 May 2025 13:28:13 +1200 Subject: [PATCH] . --- runner/jt.sh | 20 ++++++++++++++++++++ runner/src/runner.cpp | 22 ++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100755 runner/jt.sh diff --git a/runner/jt.sh b/runner/jt.sh new file mode 100755 index 0000000..d326df1 --- /dev/null +++ b/runner/jt.sh @@ -0,0 +1,20 @@ +#!/bin/bash + + +# JSON=$(cat <<'EOF' +# {"command":"nano","args":["-w","./hello.txt"]} +# EOF +# ) + +JSON=$(cat <<'EOF' +{"command":"nano","args":["-w","./hello.txt"],"ssh":{"host":"localhost","user":"j","key":"auto"},"options":{"interactive":true},"env":{"TERM":"xterm-256color"}} +EOF +) + + +BASE64=$(echo -n "$JSON" | base64 -w0) +echo "JSON: $JSON" +echo "Running command..." +build/runner "$BASE64" + + diff --git a/runner/src/runner.cpp b/runner/src/runner.cpp index d041f4a..1e9bfa6 100644 --- a/runner/src/runner.cpp +++ b/runner/src/runner.cpp @@ -424,15 +424,21 @@ int Runner::execute_ssh( } if (interactive) { - // Request a pseudo-terminal for interactive commands - rc = ssh_channel_request_pty(channel); + // Request a pseudo-terminal for interactive commands with specific term type + const char* term_type = "xterm-256color"; + rc = ssh_channel_request_pty_size(channel, term_type, 80, 24); if (rc != SSH_OK) { - std::cerr << "Error requesting PTY: " << ssh_get_error(session) << std::endl; - ssh_channel_close(channel); - ssh_channel_free(channel); - ssh_disconnect(session); - ssh_free(session); - return -1; + // Fallback to basic PTY request + std::cerr << "Warning: Could not set PTY with size, falling back to basic PTY" << std::endl; + rc = ssh_channel_request_pty(channel); + if (rc != SSH_OK) { + std::cerr << "Error requesting PTY: " << ssh_get_error(session) << std::endl; + ssh_channel_close(channel); + ssh_channel_free(channel); + ssh_disconnect(session); + ssh_free(session); + return -1; + } } }