def run_command(command, instance, key, client):
    """Executes the given command on the given EC2 instance

    Parameters
    ----------
    command : str
        The command to run (e.g. ``python run_myscript.py``)
    instance : obj
        A ``boto3`` AWS EC2 instance object.
    key : obj
        A ``paramiko.rsakey.RSAKey`` object.
    client : obj
        A ``paramiko.client.SSHClient`` object.

    Returns
    -------
    output : str
        The standard output from running the command
    errors : str
        The standard error output from running the command
    """

    client.connect(hostname=instance.public_dns_name, username='ec2-user', pkey=key)
    stdin, stdout, stderr = client.exec_command(command)
    output = stdout.read()
    errors = stderr.read()

    # Make output a more readable
    output = output.decode("utf-8")
    output = output.replace('\t', '  ').replace('\r', '').replace("\'", "").split('\n')
    errors = errors.decode("utf-8")
    errors = errors.replace('\t', '  ').replace('\r', '').replace("\'", "").split('\n')

    return output, errors