sshwot/src/main-export-known-hosts.py

25 lines
568 B
Python

import sys
import process_known_hosts
import write_file
def main():
# TODO: Handle errors
# TODO: Add a switch for whether you want to include IPs
with open(sys.argv[1], 'r') as f:
try:
entries = process_known_hosts.process_file(f)
except Exception as err:
print('Error: %s' % err, file=sys.stderr)
sys.exit(1)
# Write to stdout by default
# TODO: Add a way to change it
# We use sys.stdout.buffer instead of just sys.stdout because we
# are writing binary data
write_file.write(sys.stdout.buffer, entries)
if __name__ == '__main__':
main()