Reputation: 41
My working directory is /data/local/tmp
.
I create and push a shell script file here named get_meminfo.sh
.
The core function of it is record the RSS usage and save as a log file, like this: rss_res >> rss.log
But now I find a problem: I can run the script file when I enter the android shell, like ./get_meminfo.sh, and I can see the log file created in the path.
However when I try to run it from adb, like: adb shell /data/local/tmp/get_meminfo.sh
, it will get an error: can't create file, read-only file system!
Upvotes: 2
Views: 980
Reputation: 31686
It seems that you do not quite understand the concept of the current working dirtectory.
The rss_res >> rss.log
command creates rss.log
in the current working dirtectory. Which in case of the following command sequence is /data/local/tmp
:
adb shell
cd /data/local/tmp
./get_meminfo.sh
So rss.log
gets created in /data/local/tmp
which is world writable.
But in case of adb shell /data/local/tmp/get_meminfo.sh
the cwd is the /
root folder. Which is not writable and the command fails.
The easiest way to mitigate that is to use the absolute path for your log file inside of your script like this rss_res >> /data/local/tmp/rss.log
Upvotes: 1