def run(url, cmd, log_path, log_level, log_session, force_discovery, print_info):
    """Run the main function."""
    log_level = log_levels[log_level]
    conn = condoor.Connection("host", list(url), log_session=log_session, log_level=log_level, log_dir=log_path)
    try:
        conn.connect(force_discovery=force_discovery)
        if print_info:
            echo_info(conn)

        for command in cmd:
            result = conn.send(command)
            print("\nCommand: {}".format(command))
            print("Result: \n{}".format(result))
    except (condoor.ConnectionError, condoor.ConnectionAuthenticationError, condoor.ConnectionTimeoutError,
            condoor.InvalidHopInfoError, condoor.CommandSyntaxError, condoor.CommandTimeoutError,
            condoor.CommandError, condoor.ConnectionError) as excpt:
        click.echo(excpt)
    finally:
        conn.disconnect()
    return