The "broken pipe" exception means the process on the other end is
gone.

This won't give a SecurityException, because it's not Java that's
checking the permissions.

Connect to the phone via 'adb -d shell' and type 'su' followed by
Enter.

What happens? (You may need to add the tools directory from your SDK
to your path first, or type the entire path to adb.exe -- or
equivalent if you're using Linux or OSX. Use -e instead of -d if using
the emulator instead of a phone. See the docs if you have more than
one).

If it just works, then download Better Terminal Emulator (I think
there's a free version but the better one is better) and try it from
there. What happens?

Check your $PATH variable, and use that to locate where the su program
is located. Supply that in your exec() call.

But be aware that the path is likely to be different on phones rooted
via a different procedure! Using 'su' -- and doing anything requiring
root permission, or anything using anything added by a rooting
procedure, is not supported, so you'll have to do considerably more
legwork to iron out the compatibility issues.

Not to mention, you'll be limited to customers who have voided their
warranties and rooted their phones.

On Feb 8, 2:51 am, Asif k <[email protected]> wrote:
> I got somewhere on the net following code, I tried to execute but it
> throws "broken pipe: IOException" at
>
> os.writeBytes(single + "\n"); line....
>
> Following is the code..
>
> Process process = Runtime.getRuntime().exec("su"); DataOutputStream?
> os = new DataOutputStream?(process.getOutputStream());
> DataInputStream? osRes = new DataInputStream?
> (process.getInputStream()); for (String single : commands) {
>
> os.writeBytes(single + "\n"); os.flush(); res.add(osRes.readLine());
>
> } os.writeBytes("exit\n"); os.flush(); process.waitFor();
>
> Any idea..
> Please help...
> Asif
>
> On Feb 4, 6:23 pm, Asif k <[email protected]> wrote:
>
>
>
> > Is it possible to spawn a new process from the activity with su mode
> > and then run the script??
> > i had given the shell script as bellow but does not give fruitful
> > output,
>
> > stored in the device: /data/local/hello.sh
> > #!/system/bin/sh
> > (ifconfig wlan0 up)su
> > exit
>
> > and form Java code,
>
> > Process process = Runtime.getRuntime.exec("/data/local/hello.sh");
>
> > Can anyone please help me on this????
>
> > Thanks,
> > Asif
> > On Feb 4, 11:39 am, Asif k <[email protected]> wrote:
>
> > > Hi all,
>
> > >    I am running a shell script stored in the device from android
> > > application by creating instance of Process class.
> > >   But my script has commands which will be executed only in "su" mode.
> > > any idea how to accomplish this?
>
> > > Thanks,
> > > Asif- Hide quoted text -
>
> > - Show quoted text -

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

Reply via email to