a method to run a list of shell command scripts on AWS instance

        :param commands: list of strings with shell commands to pass through connection
        :param synopsis: [optional] boolean to simplify progress messages to one line
        :return: string with response to last command

def script(self, commands, synopsis=True):

        '''
            a method to run a list of shell command scripts on AWS instance

        :param commands: list of strings with shell commands to pass through connection
        :param synopsis: [optional] boolean to simplify progress messages to one line
        :return: string with response to last command
        '''

        title = '%s.script' % self.__class__.__name__

    # validate inputs
        if isinstance(commands, str):
            commands = [commands]
        input_fields = {
            'commands': commands
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)

    # run commands through paramiko on Windows
        response = ''
        if self.localhost.os.sysname in ('Windows'):
            ssh_key = paramiko.RSAKey.from_private_key_file(self.pem_file)
            client = paramiko.SSHClient()
            client.load_system_host_keys()
            client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            client.connect(hostname=self.instance_ip, username=self.ec2.iam.user_name, pkey=ssh_key)
            for i in range(len(commands)):
                self.ec2.iam.printer('[%s@%s]: %s ... ' % (self.login_name, self.instance_ip, commands[i]), flush=True)
                std_in, std_out, std_err = client.exec_command(commands[i], get_pty=True)
                if std_err:
                    self.ec2.iam.printer('ERROR.')
                    raise Exception('Failure running [%s@%s]: %s\n%s' % (self.login_name, self.instance_ip, commands[i], std_err.decode('utf-8').strip()))
                else:
                    response = std_out.decode('utf-8')
                    if synopsis:
                        self.ec2.iam.printer('done.')
                    else:
                        if response:
                            self.ec2.iam.printer('\n%s' % response)
                        else:
                            self.ec2.iam.printer('done.')
            client.close()

    # run command through ssh on other platforms
        else:
            from subprocess import Popen, PIPE, STDOUT
            for i in range(len(commands)):
                self.ec2.iam.printer('[%s@%s]: %s ... ' % (self.login_name, self.instance_ip, commands[i]), flush=True)
                sys_command = 'ssh -i %s %s@%s %s' % (self.pem_file, self.login_name, self.instance_ip, commands[i])
                # DEBUG print(sys_command)
                pipes = Popen(sys_command.split(), stdout=PIPE, stderr=STDOUT)
            # automatically accept keys
                std_out, std_err = pipes.communicate('yes\n'.encode('utf-8'))
                if pipes.returncode != 0:
                    self.ec2.iam.printer('ERROR.')
                    raise Exception('Failure running [%s@%s]: %s\n%s' % (self.login_name, self.instance_ip, commands[i], std_out.decode('utf-8').strip()))

        # report response to individual commands
                else:
                    response = std_out.decode('utf-8')
                    if synopsis:
                        self.ec2.iam.printer('done.')
                    else:
                        if response:
                            self.ec2.iam.printer('\n%s' % response)
                        else:
                            self.ec2.iam.printer('done.')

    # close connection and return last response
        return response