Change TMPDIR for Android shell script I am working on a script that will be run from an android shell (e.g. adb shell). I have a problem with writing temporary files, as this demonstrates:

$ cat &lt;&lt;-EOF &gt; foo
&gt; EOF
sh: can't create temporary file /data/local/shd1v7x1.tmp: Permission denied


I want to direct the shell's temporary directory to somewhere that is writable. I would usually do this:

$ export TMPDIR=/path/to/somwehere/writable
$ cat &lt;&lt;-EOF &gt; foo


but it makes no difference.

Is it possible to specify the location the shell should use for temporary files?

(I know that running as root is a work around but that isn't a solution)
/data/local/tmp should be writable on all Android and it works with that :-).

export TMPDIR=/data/local/tmp