Are you using a rooted phone?

Elevated privileges will be refused on a stock build. I'm not sure
what the actual effect will be. I would expect a SecurityException,
but it's possible that the "su" program is simply not visible to
user-space processes.

Also, you are not specifying the full path to the su program, I doubt
it will be included in your PATH.

What is it you're trying to achieve? That code looks very vulnerable
to attacks...


On Mon, Feb 8, 2010 at 10: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

-- 
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