From c84e482a65029a48c38a47f6bd54933c8f865b45 Mon Sep 17 00:00:00 2001 From: George Kelly Date: Thu, 8 Oct 2020 14:07:05 +0100 Subject: [PATCH 1/2] No longer trims newlines --- lib/oxidized/script/cli.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/oxidized/script/cli.rb b/lib/oxidized/script/cli.rb index b5715be..5cf66bf 100644 --- a/lib/oxidized/script/cli.rb +++ b/lib/oxidized/script/cli.rb @@ -126,7 +126,6 @@ def run_file file out = '' file = file == '-' ? $stdin : File.read(file) file.each_line do |line| - line.chomp! # line.sub!(/\\n/, "\n") # treat escaped newline as newline out += @oxs.cmd line end From 7981af1e6b844841f793b6d45e97cc0c55938460 Mon Sep 17 00:00:00 2001 From: George Kelly Date: Thu, 8 Oct 2020 14:22:55 +0100 Subject: [PATCH 2/2] Added no-trim option --- lib/oxidized/script/cli.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/oxidized/script/cli.rb b/lib/oxidized/script/cli.rb index 5cf66bf..3f04a10 100644 --- a/lib/oxidized/script/cli.rb +++ b/lib/oxidized/script/cli.rb @@ -91,6 +91,7 @@ def opts_parse cmds slop.on '--regex=', 'run on all hosts that match the regexp' slop.on '--dryrun', 'do a dry run on either groups or regexp to find matching hosts' slop.on '--protocols=','protocols to use, default "ssh, telnet"' + slop.on '--no-trim', 'Dont trim newlines and whitespace when running commands' slop.on 'v', '--verbose', 'verbose output, e.g. show commands sent' slop.on 'd', '--debug', 'turn on debugging' slop.on :terse, 'display clean output' @@ -127,6 +128,7 @@ def run_file file file = file == '-' ? $stdin : File.read(file) file.each_line do |line| # line.sub!(/\\n/, "\n") # treat escaped newline as newline + line.chomp! unless @opts["no-trim"] out += @oxs.cmd line end out