Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I need to run a configure file into my android phone so I think the best way to do this is to use the adb shell command.

I'm running an Android emulator onto a Windows-7 platform, and there I'm running the adb shell command into a DOS window. Using the cd command I'm changing to the directory where my configure file is, and then I'm executing the following command: ./configure. I'm getting the following error :

./configure: permission denied

So I try to run adb in root mode with adb root -- but apparently my adb is already in root mode (Moreover I have the "#" character before each line of my adb shell).

I have also tried to use chmod but I don't see any difference before and after executing this command (ls -la), so maybe the problem is here (How can I run the chmod command?).

Maybe someone here can help me with my issue, and if you have also an explanation about why I don't have the permission to run my configure file it will be great.

Thanks.

PS: My goal here is to use the net-snmp package on an Android platform by compiling the sources of this project directly onto the platform.

share|improve this question
2  
That's probably the problem. /sdcard is typically mounted with the noexec flag in Android, so you can't execute binaries from it. I would recommend trying to move it to somewhere else (often /data/local is used for things like that). See if that solves the problem. –  eldarerathis Dec 18 '12 at 15:39
2  
Also, copy it to the /usr/local/tmp directory (the entire net-snmp-5.7.2 directory in /sdcard. –  Liam W Dec 18 '12 at 15:39
1  
@t0mm13b Not entirely sure if this is off topic, as it could be useful for people that need to execute a file on their device, such as a root exploit. –  Liam W Dec 18 '12 at 17:06
1  
Ok thanks. My question here was more about how can I run a script sh with the adb shell than a development question. But now I have the solution : "/sdcard is mounted with the noexec flag", so if eldarerathis or Liam W wants to put their comment into a real answer I will validate it. Or maybe you can explained me how can I close my question? –  grattmandu03 Dec 18 '12 at 17:10
1  
@grattmandu03 I already have ;) –  Liam W Dec 18 '12 at 17:13
show 13 more comments

2 Answers 2

up vote 5 down vote accepted

This is due to 2 things:

  1. The file does not have execute permissions [AND]
  2. The file cannot gain executable permissions as it is on the SD Card. The SD Card's filesystem can accept file permissions, however it is mounted with the noexec flag, as stated in a comment. This stops files being executed.

Solution:

  1. Copy the net-snmp-5.7.2 directory to the /data/local/tmp directory as root.
  2. Set the configure file to be executable by running chmod 0777 /data/local/tmp/net-snmp-5.7.2/configure as root.
  3. You should now be able to execute the configure script by typing /data/local/tmp/net-snmp-5.7.2/configure and pressing enter.

Note

This should all be done as the root user :)

share|improve this answer
add comment

As explained by the comments and Liam's answer, this is due to the noexec flag used by the system when mounting the sdcard. If your configure file is a shell script (as it usually is), you can still trick it to be executed:

cd to the directory as you described above, and then execute sh configure.

sh is the Shell interpreter, and that binary should be located in /system/bin, where files are executable. Passing your script as the first argument, this will open a new shell process which executes your configure script.

share|improve this answer
    
Thanks for your answer. The sh configure does the trick. –  grattmandu03 Dec 19 '12 at 8:12
1  
Thanks for the confirmation! And glad I was able to help. I use this trick on Linux/Unix machines from time to time :) –  Izzy Dec 19 '12 at 8:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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