Dir::tmpdir will be on the machine running metasploit, not in the target machine, which I think is what you're trying to accomplish.