Thursday, July 29, 2010

Re: [android-developers] How to execute shell script file from android application

In addition to the permission restriction, no shell commands are part of the SDK, so anything using exec() is relying on private APIs and likely to break in the future or on different devices.

On Wed, Jul 28, 2010 at 3:39 AM, Suchita Sharma <suchi.bhardwaj@gmail.com> wrote:

Hi all,

I am trying to execute a shell script from application using 

java.lang.Process API.

The script file is executing properly as i am able to get logs but the line 

$SETPROP net.if.default rmnet0

is not getting executed.

has anyone able to execute .sh file from application succesfully.



Code Snippet:
//
str={"/system/bin/sh","/sdcard/test.sh"};
Process p = Runtime.getRuntime().exec(str);

//

test.sh:
LOG=/system/bin/log
SETPROP=/system/bin/setprop
$LOG -t test"++Setting up default iface"

$SETPROP net.if.default rmnet0
$LOG -t test"++Setting done "

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Dianne Hackborn
Android framework engineer
hackbod@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate