From 27b8b22c6e5561bbcca0d72fb74d395424e47f3c Mon Sep 17 00:00:00 2001 From: Guillaume Chazarain Date: Sat, 13 Jun 2009 23:26:20 +0200 Subject: [PATCH] Use bash --noediting by default to avoid readline problems. This means lines cannot be longer than 4096 bytes long (N_TTY_BUF_SIZE), so we insert newlines in the file transfer python code and we remove the continuation prompt (PS2: '> '). --- gsh.1 | 2 +- gsh/file_transfer.py | 3 ++- gsh/main.py | 2 +- gsh/remote_dispatcher.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gsh.1 b/gsh.1 index 2d772b5..800ee05 100644 --- a/gsh.1 +++ b/gsh.1 @@ -30,7 +30,7 @@ Read hostnames from given file, one per line. Hostnames are given on the command Command to execute on the remote shells. This starts \fIgsh\fR in non\-interactive mode. It will start the remote shells, send the command, print the output and exit when the command is completed on all remote shells. This is the same as piping a command on the standard input. Exit codes from the remote shells will be aggregated (taking the max) to form \fIgsh\fR's exit code. .TP \fB\-\-ssh=SSH\fR -Ssh command to use [ssh -oLogLevel=Quiet -t %(host)s bash --noprofile]. By default, \fIgsh\fR spawns lightweight remote shells using the ssh command, but another shell command can be specified here. For example, with \-\-ssh='usleep $((RANDOM*50)); exec ssh' a delay will be introduced to avoid all hosts accessing a NFS server at the same time. If the hostname should not be added at the end of the command, the macro %(host)s can be inserted where the hostname should be placed. Also, make sure the command you use launchs a pty, this may need the \-t option for ssh. +Ssh command to use [ssh -oLogLevel=Quiet -t %(host)s bash --noprofile --noediting]. By default, \fIgsh\fR spawns lightweight remote shells using the ssh command, but another shell command can be specified here. For example, with \-\-ssh='usleep $((RANDOM*50)); exec ssh' a delay will be introduced to avoid all hosts accessing a NFS server at the same time. If the hostname should not be added at the end of the command, the macro %(host)s can be inserted where the hostname should be placed. Also, make sure the command you use launchs a pty, this may need the \-t option for ssh. .TP \fB\-\-log\-file=LOG_FILE\fR File to log each machine conversation [none]. If specified, \fIgsh\fR will log all executed commands and their output in the file. The logging destination can be dynamically changed with the :set_log control command. diff --git a/gsh/file_transfer.py b/gsh/file_transfer.py index f9f9951..cc76695 100644 --- a/gsh/file_transfer.py +++ b/gsh/file_transfer.py @@ -58,7 +58,8 @@ def base64version(): if line: python_lines.append(line) python_source = '\n'.join(python_lines) - encoded = base64.encodestring(python_source).rstrip('\n').replace('\n', ',') + encoded = base64.encodestring(python_source).rstrip('\n') + encoded = encoded.replace('\n', ',\\\n') return encoded def file_transfer_cb(dispatcher, host_port): diff --git a/gsh/main.py b/gsh/main.py index cd1d74b..2b34d9c 100644 --- a/gsh/main.py +++ b/gsh/main.py @@ -60,7 +60,7 @@ def parse_cmdline(): parser.add_option('--command', type='str', dest='command', default=None, help='command to execute on the remote shells', metavar='CMD') - def_ssh = 'ssh -oLogLevel=Quiet -t %(host)s bash --noprofile' + def_ssh = 'ssh -oLogLevel=Quiet -t %(host)s bash --noprofile --noediting' parser.add_option('--ssh', type='str', dest='ssh', default=def_ssh, metavar='SSH', help='ssh command to use [%s]' % def_ssh) parser.add_option('--log-file', type='str', dest='log_file', diff --git a/gsh/remote_dispatcher.py b/gsh/remote_dispatcher.py index 203feb7..125ebf5 100644 --- a/gsh/remote_dispatcher.py +++ b/gsh/remote_dispatcher.py @@ -154,7 +154,7 @@ class remote_dispatcher(buffered_dispatcher): """The prompt is important because we detect the readyness of a process by waiting for its prompt.""" # No right prompt - command_line = 'RPS1=;RPROMPT=;' + command_line = 'PS2=;RPS1=;RPROMPT=;' command_line += 'PROMPT_COMMAND=;' command_line += 'TERM=ansi;' command_line += 'unset HISTFILE;' -- 2.11.4.GIT