9

I'm testing an app that uses the System temp Directory. Inside of the app, there is some call to a Cocoa function to query this. Is there a way for me to query for this directory name outside of having to write a Cocoa app of my own? Possibly a command that I can issue in Terminal?

1

2 Answers 2

18
env

Just type this command into Terminal. With zero arguments it'll print the names and values of variables in the environment.

Alternative with a bit more typing:

echo $TMPDIR
2
  • 2
    Thanks. What a weird path - /var/folders/iz/izqn2b5MF-iz9oL0CURH1U+++TI/-Tmp-/
    – bpapa
    Commented Nov 13, 2010 at 20:32
  • 3
    This is not a good answer, since this env variable points to different directory every time a different process is invoked. It is made to let each process freely write into a "temp" directory, without worrying that it might overwrite (or read by mistake) something another application wrote. Commented Apr 4, 2016 at 10:08
5

OS X has Python pre-installed, though not necessarily a fresh Python; but this is not cutting-edge stuff.

So:

Open a terminal

cat > hack.py
import tempfile
print tempfile.gettempdir()
^D
python hack.py

Credit to nosklo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .