I would like to be able to fetch the value of the EXTERNAL_STORAGE
variable on my Android handset from an ant build.xml
script running on OS X so that I can subsequently perform an adb push
of a file to that location on the handset.
When I am shelled into the handset, I can see the value just fine:
$ adb shell
shell@android:/ $ echo $EXTERNAL_STORAGE
/mnt/sdcard
When I try to get that value back on OS X using a one-line adb shell
command, I get nothing:
$ adb shell "echo $EXTERNAL_STORAGE"
Any ideas on how to get this to work?
You need to escape the $
. Like this:
adb shell "echo \$EXTERNAL_STORAGE"
Otherwise shell variable expansion happens locally before the command gets sent to the device and your command ends up being adb shell "echo "
since the local $EXTERNAL_STORAGE
is not set.