diff --git a/hostnames.json b/hostnames.ini similarity index 100% rename from hostnames.json rename to hostnames.ini diff --git a/ssh-host.py b/ssh-host.py index cefde3c..1a47426 100644 --- a/ssh-host.py +++ b/ssh-host.py @@ -1,13 +1,17 @@ #!/usr/bin/python import subprocess import argparse -import json -with open(‘hostnames.json’) as file: -hostnames = json.load(file) -parser = argparse.ArgumentParser() -parser.add_argument(‘-o’,’—-wan’,action = ‘store_true’) -parser.add_argument(‘name’,help=‘name of config file to use (sans .cfg)’) -parser.add_argument(‘arg’,nargs = ‘*’) -args = parser.parse_args() -cmd = [‘ssh’,’-F’,’~/.ssh/{}.cfg’.format(args.name)] -subprocess.call( \ No newline at end of file +import configparser +cp = configparser.ConfigParser(interpolate=configparser.ExtendedInterpolation()) +cp.read('hostnames.ini') +if __name__ == "__main__": + parser = argparse.ArgumentParser() + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument('-o','—-wan',action = 'store_true') + group.add_argument('-l','--lan',action = 'store_true') + parser.add_argument('-p','--pre-script', help= 'script to run before connecting(in config dir)') + parser.add_argument('name',help='name of config file to use (sans .cfg)') + parser.add_argument('arg',nargs = '*') + args = parser.parse_args() + cmd = ['ssh','-F','~/.ssh/{}.cfg'.format(args.name)] + subprocess.call(cmd)