From 0842d4627e9b8d534d1d57218be9f86fca7402d8 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 21 Apr 2019 14:09:45 +0100 Subject: [PATCH] kh2reg.py: add -o option to write output to a file. Generally useful, I always think. --- contrib/kh2reg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/kh2reg.py b/contrib/kh2reg.py index ea8ff23d..32b871d0 100755 --- a/contrib/kh2reg.py +++ b/contrib/kh2reg.py @@ -382,12 +382,15 @@ def main(): "--unix", action='store_const', dest="output_formatter_class", const=UnixOutputFormatter, help="Produce a file suitable for use as ~/.putty/sshhostkeys.") + parser.add_argument("-o", "--output", type=argparse.FileType("w"), + default=argparse.FileType("w")("-"), + help="Output file to write to (default stdout).") parser.add_argument("infile", nargs="*", help="Input file(s) to read from (default stdin).") parser.set_defaults(output_formatter_class=WindowsOutputFormatter) args = parser.parse_args() - output_formatter = args.output_formatter_class(sys.stdout) + output_formatter = args.output_formatter_class(args.output) output_formatter.header() for line in fileinput.input(args.infile): handle_line(line, output_formatter)