Temp folder in Macos under root

mac-osxrootscripting

I'm eriting a MacOS script that need to run under admin rights (under 'sudo'). Script needs a temp folder in order to keep some temp files. Unfortunately, there is no 'TMPDIR' under root! If i run 'env' i see TMPDIR with a nice temp path. If i run 'sudo env' i don't see TMPDIR :(. Is it any way to obtain correct "temp folder" path under root?

Best Answer

If there's a $TMPDIR, use it. Otherwise use /tmp (it should exist on Mac too).

Related Topic