0

I am using a tool called Droidbox for experiment. The tool has a shell script droidbox.sh which I can invoke through terminal.

droidbox.sh takes one argument i.e path of the apk

Usage: ./droidbox.sh APK

I want to call the droidbox.sh through a shell script.

I wrote a shell script like

#!/bin/bash
ARG1="/home/xxx/a.apk"
/home/xxx/DroidBox_4.1.1/droidbox.sh "$ARG1"

I am getting error which says

python: can't open file 'scripts/droidbox.py': [Errno 2] No such file or directory

Can anybody point out what am I doing wrong?

2
  • 1
    droidbox.sh is expecting to be run from the DroidBox_4.1.1 directory (which presumably is where you are running it from manually). It can't find the scripts/droidbox.py file it expects in your current directory when you run that script. That's a poorly written script (not yours, droidbox.sh). Commented Sep 10, 2014 at 17:59
  • if you run an "ls" in the same directory you're executing your script in, do you see the "scripts/droidbox.py" folder/file? Commented Sep 10, 2014 at 18:00

2 Answers 2

2

Your error message does not come from your script, but from the called one.

It sounds like the droidbox.sh script is not very smart and requires you to set the current working directory before you can call it.

I would typically use also some more variables, so you better see what belongs together:

#!/bin/sh
set -e
BASEDIR="/home/xxx" 
DROIDDIR="$BASEDIR/DrroidBox_4.1.1"
APKFILE="$BASEDIR/a.apk"
cd "$DROIDDIR"
"$DROIDDIR/droidbox.sh" "$APKFILE"

If you dont use set -e you better combine commands which need to succeed together:

cd "$DROIDDIR" && "$DROIDDIR/droidbox.sh" "$APKFILE"

Otherwise the cd might fail when the directory is missing and all following commands execute in the wrong directory.

Sign up to request clarification or add additional context in comments.

Comments

1

This error is because you're running the script in a different folder than the folder that houses your "scripts/droidbox.py" file. You can fix this in the following way(s):

  1. Move the "scripts/" folder to the directory that you're running this script out of using "mv /path/to/scripts/ ."
  2. Move your customer script to the folder that contains scripts/droidbox.py and run the script from there

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.