Bash script for pulling db from emulator permission denied

I’m trying to create shell script to pull the database from my Genymotion emulator.

I’ve come up with this:

#!/bin/bash

REQUIRED_ARGS=2
ADB_PATH=~/.android/adb.bash
PULL_DIR="~/"

if [ $# -ne $REQUIRED_ARGS ]
    then
        echo ""
        echo "move.sh [package_name] [db_name]"
        echo "eg. ./move.sh test.example.com test.db"
        echo ""
    exit 1
fi;


echo""

cmd1="$ADB_PATH shell cp /data/data/$1/databases/$2 /mnt/shell/emulated/0/Download/$2"
cmd2="$ADB_PATH pull /mnt/shell/emulated/0/Download/$2 $PULL_DIR"

echo $cmd1
eval $cmd1
if [ $? -eq 0 ]
    then
    echo ".........Success"
fi;

echo $cmd2
eval $cmd2

if [ $? -eq 0 ]
    then
    echo ".........Success"
fi;

exit 0

When I execute the script I get:

/Users/user/.android/adb.bash shell cp /data/data/user.be.gins/databases/Gins.db /mnt/shell/emulated/0/Download/Gins.db
./move.sh: line 24: /Users/user/.android/adb.bash: Permission denied
/Users/user/.android/adb.bash pull /mnt/shell/emulated/0/Download/Gins.db ~/
./move.sh: line 31: /Users/user/.android/adb.bash: Permission denied

When I execute it as sudo still the same problem. When I just do the commmand by myself everything works.

Anyone an idea?


Source: shell

Leave a Reply