Removed the ssh argument code that uses --.

Added --ssh which can be used to change the ssh executable and pass arugments, it also lets you do things like:

./crussh --ssh telnet "www.google.com 80" "www.bing.com 80"
This commit is contained in:
Jeff Fisher 2012-03-21 14:09:46 -06:00
parent f0b74c5b1f
commit fde90035af

View File

@ -265,7 +265,7 @@ class CruSSH:
# give EntryBox default focus on init
self.EntryBox.props.has_focus = True
def __init__(self, hosts, ssh_args=None):
def __init__(self, hosts, ssh_cmd="/usr/bin/ssh"):
# load existing config file, if present
try:
# merge dicts to allow upgrade from old configs
@ -279,10 +279,7 @@ class CruSSH:
terminal = vte.Terminal()
# TODO: disable only this terminal widget on child exit
# v.connect("child-exited", lambda term: gtk.main_quit())
cmd_str = "/usr/bin/ssh"
if ssh_args is not None:
cmd_str += " " + ssh_args
cmd_str += " " + host
cmd_str = "%s %s" % (ssh_cmd, host)
cmd = cmd_str.split(' ')
terminal.fork_command(command=cmd[0], argv=cmd)
self.Terminals[host] = terminal
@ -299,23 +296,13 @@ if __name__ == "__main__":
import argparse
### Parse CLI Args ###
parser = argparse.ArgumentParser(
description="Connect to multiple servers in parallel.",
usage="%(prog)s [OPTIONS] [--] HOST [HOST ...]",
epilog="* NOTE: You can pass options to ssh if you add '--' before your list of hosts")
(args, hosts) = parser.parse_known_args()
if len(hosts) == 0:
parser.print_usage()
parser.exit(2)
if "--" in hosts:
offset = hosts.index("--") + 1
ssh_args = " ".join(hosts[0:offset])
hosts = hosts[offset:]
else:
ssh_args = None
parser = argparse.ArgumentParser(description="Connect to multiple servers in parallel.")
parser.add_argument('hosts', metavar='HOST', nargs='+',
help="Host(s) to connect to.")
parser.add_argument("--ssh", dest='ssh', default="/usr/bin/ssh",
help="SSH executable and optional arguments (ex: --ssh 'ssh -l root')")
args = parser.parse_args()
### Start Execution ###
crussh = CruSSH(hosts, ssh_args)
crussh = CruSSH(args.hosts, args.ssh)
gtk.main()