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 <<-EOF > foo
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 <<-EOF > 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
| improve this answer | |
  • yes, that works. I guess I must not have known of that location when I asked the question but I know about it now. – starfry Jan 16 '18 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.