'Simulates the execution of dsmc, rm, and ln commands.'

def exec_cmd(self, cmd):

    if (cmd[0] == 'dsmc'):
        (out, err, ret) = self._exec_dsmc_cmd(cmd)
    elif (cmd[0] == 'ln'):
        dest = cmd[2]
        out = ''
        if (dest in self._hardlinks):
            err = ("ln:    failed    to    create    hard    link    `%s':    File    exists" % dest)
            ret = 1
        else:
            self._hardlinks.append(dest)
            err = ''
            ret = 0
    elif (cmd[0] == 'rm'):
        dest = cmd[2]
        out = ''
        if (dest not in self._hardlinks):
            err = ("rm:    cannot    remove    `%s':    No    such    file    or    directory" % dest)
            ret = 1
        else:
            index = self._hardlinks.index(dest)
            del self._hardlinks[index]
            err = ''
            ret = 0
    else:
        raise putils.ProcessExecutionError(exit_code=1, stdout='', stderr='Unsupported    command', cmd='    '.join(cmd))
    return (out, err, ret)
