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