def shim_cmd(self, cmd_str):
        '''
        Run a shim command.

        If tty is enabled, we must scp the shim to the target system and
        execute it there
        '''
        if not self.tty:
            return self.shell.exec_cmd(cmd_str)

        # Write the shim to a temporary file in the default temp directory
        with tempfile.NamedTemporaryFile(mode='w',
                                         prefix='shim_',
                                         delete=False) as shim_tmp_file:
            shim_tmp_file.write(cmd_str)

        # Copy shim to target system, under $HOME/.<randomized name>
        target_shim_file = '.{0}'.format(binascii.hexlify(os.urandom(6)))
        self.shell.send(shim_tmp_file.name, target_shim_file)

        # Remove our shim file
        try:
            os.remove(shim_tmp_file.name)
        except __HOLE__:
            pass

        # Execute shim
        ret = self.shell.exec_cmd('/bin/sh \'$HOME/{0}\''.format(target_shim_file))

        # Remove shim from target system
        self.shell.exec_cmd('rm \'$HOME/{0}\''.format(target_shim_file))

        return ret
dataset/ETHPy150Open saltstack/salt/salt/client/ssh/__init__.py/Single.shim_cmd