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 tried executing a script on the sdcard as is because on FAT, everything is 777.

./.profile
./.profile: permission denied

I added this as the initial command for the Android shell and it executes it just fine:

eval "$(cat /sdcard/.profile)"

So what I'm wondering is: Is there a way I can execute a script on the sdcard (other than the way I found out) and be able to pass arguments to it or do I need to do it the normal BTEP way (in its data directory)?

share|improve this question
1  
Does sh .profile arg1 arg2 works? –  Lie Ryan Aug 9 '12 at 5:49
    
You know what, that's a good idea. I have to stop over complicating things :-P –  biggles5107 Aug 10 '12 at 21:35

2 Answers 2

up vote 1 down vote accepted

Moved from comments and expanded.

Invoking the script with the shell directly sh .profile arg1 arg2 should work. If it become cumbersome to invoke the shell and typing the arguments, you can also create an alias, most terminal emulators allows you to specify an initial command to run at the start of a session.

share|improve this answer

You will probably be unable to directly execute scripts from your sdcard. At least without root. Reason is, with most ROMs sdcards are mounted using the noexec flag -- which means, as the term suggests: "no exec from here". Of course, having root you could simply remount the sdcard while removing this option.

Why might this option be forced? I'd say for security reasons. While on internal storage, apps are quite limited regarding where they might write to, on sdcards they can write everywhere. So this could be used by some "evil guys/girls" to place their malware scripts -- but that's just a guess.

share|improve this answer
    
That makes sense. –  biggles5107 Aug 10 '12 at 21:35

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.