[Q]Problem splitting the string in 'ls -l path' command - Java for Android App Development

i am using Roottools library to list files of a path using ls -l path
Code:
public static void getFilesList(String path,boolean root)
{
String ls = runAndWait("ls -l " + path,root);
if (ls == null)
{
return;
}
if (ls.equals("\n") || ls.equals(""))
{
return;
}
else
{
List<String> files = Arrays.asList(ls.split("\n"));
for (String file : files)
{
//i want to split this string into values
System.out.println(file);
}
}
}
Output of this method is like this
Code:
I/System.out﹕ -rw-rw---- root sdcard_r 23990791 2014-08-08 20:57 net.mobilecraft.parkingmadness-1.apk
I/System.out﹕ -rw-rw---- root sdcard_r 1690424 2014-08-08 20:57 nl.ndsc.kitkatlauncher-1.apk
i tried to split the values using
Code:
String[] array=line.split(" ");
but it creates problem for following type of ouputs
Code:
I/System.out﹕ lrwxrwxrwx root root 2014-08-09 19:06 bugreports -> /data/data/com.android.shell/files/bugreports
I/System.out﹕ drwxrwx--- root sdcard_r 2014-08-10 08:47 new folder
here if the file name has a space or a symlink then it results in error.i want a method which can split these type of string and return correct values

Related

System read-only exception (While it isn't)

Apps runs with root permissions
Code:
//Requesting root
try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
}
I'm trying to save script to init.d folder
Code:
public void WriteScript(View view) {
Save("/system/etc/init.d/10zram", getString(R.string.sys_script), false);
}
Code:
public static void Save(String file, String textToSave, boolean overwrite) {
Log.w("Advanced ZRAM", "Writer start");
if (overwrite) new File(file).delete();
try {
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write(textToSave);
out.close();
} catch (IOException error) { Log.e("Advanced ZRAM", "File saving failed", error);
}
}
And have this exception.
Code:
05-14 14:56:08.691: ERROR/Advanced ZRAM(31270): File saving failed
java.io.FileNotFoundException: /system/etc/init.d/10zram: open failed: EROFS (Read-only file system)
at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
at java.io.FileWriter.<init>(FileWriter.java:80)
at test.zrammgr.Configurator.Save(Configurator.java:36)
at test.zrammgr.Configurator.WriteScript(Configurator.java:23)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3594)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17355)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5226)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:400)
... 20 more
Why it can't write to /system? I have remouted /system via ADB shell, but this didn't helped
Code:
adb shell
[email protected]:/ $ su
su
[email protected]:/ # mount -o rw,remount /system
mount -o rw,remount /system
[email protected]:/ # cd /system
cd /system
[email protected]:/system # touch test
touch test
[email protected]:/system #
test appeared
GR0S said:
Apps runs with root permissions
Code:
//Requesting root
try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
}
I'm trying to save script to init.d folder
Code:
public void WriteScript(View view) {
Save("/system/etc/init.d/10zram", getString(R.string.sys_script), false);
}
Code:
public static void Save(String file, String textToSave, boolean overwrite) {
Log.w("Advanced ZRAM", "Writer start");
if (overwrite) new File(file).delete();
try {
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write(textToSave);
out.close();
} catch (IOException error) { Log.e("Advanced ZRAM", "File saving failed", error);
}
}
And have this exception.
Code:
05-14 14:56:08.691: ERROR/Advanced ZRAM(31270): File saving failed
java.io.FileNotFoundException: /system/etc/init.d/10zram: open failed: EROFS (Read-only file system)
at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
at java.io.FileWriter.<init>(FileWriter.java:80)
at test.zrammgr.Configurator.Save(Configurator.java:36)
at test.zrammgr.Configurator.WriteScript(Configurator.java:23)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3594)
at android.view.View.performClick(View.java:4204)
at android.view.View$PerformClick.run(View.java:17355)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5226)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:400)
... 20 more
Why it can't write to /system? I have remouted /system via ADB shell, but this didn't helped
Code:
adb shell
[email protected]:/ $ su
su
[email protected]:/ # mount -o rw,remount /system
mount -o rw,remount /system
[email protected]:/ # cd /system
cd /system
[email protected]:/system # touch test
touch test
[email protected]:/system #
test appeared
Click to expand...
Click to collapse
afaik you have to use the runtime to move around files, you can't do it from java. At least, that is the way I do it.
Zatta said:
afaik you have to use the runtime to move around files, you can't do it from java. At least, that is the way I do it.
Click to expand...
Click to collapse
Can you share some code?
GR0S said:
Can you share some code?
Click to expand...
Click to collapse
Use the java.lang.Process you get by calling
Code:
try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
}
to invoke commands on it as described here: http://forum.xda-developers.com/showthread.php?t=2226664
For writing on /system you need to mount it rw before that. Do not forget to mount it with read-only permission afterwards! (http://forum.xda-developers.com/showthread.php?p=7257098)
Then move your files using the mv command. If you want to move files between different partitions, you will have to use "busybox mv ..." instead. (http://linux.about.com/library/cmd/blcmdl1_mv.htm)
Root features can just be used in this process the command line way. That is because Android was not designed to be rooted. Additionally every app has its own VM and cannot access to the system partition for that reason.
GR0S said:
Can you share some code?
Click to expand...
Click to collapse
For an easy implementation, use RootTools
I am using a (slightly modified) version of the ShellProvider class from the nitrality project.

Help with RootTools

Hey! I need your help!
This is all my code, I use library common-io-2.2 and RootTool library.
I have two issues:
1- Error in waitForFinish();
2- processDialog don't appear.
Code:
import android.app.*;
import android.content.*;
import android.os.*;
import android.os.Process;
import android.util.*;
import android.view.*;
import android.view.View.*;
import android.widget.Button;
import android.widget.Toast;
import java.io.*;
import com.stericson.RootTools.RootTools;
import com.stericson.RootTools.execution.CommandCapture;
import java.util.concurrent.*;
import com.stericson.RootTools.exceptions.*;
import org.apache.commons.io.*;
public class MainActivity extends Activity {
{
}
ProgressDialog progressDialog = null;
/** Called when the activity is first created. */
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if (RootTools.isAccessGiven()) {
} else {
makeToast("Se necesitan permisos de Superusuario!");
finish();
}
}
public void reparar(View view) throws IOException, TimeoutException, RootDeniedException, InterruptedException {
CopyFromAssets();
CopyFromAssetstosystem();
End();
}
public void CopyFromAssets() {
progressDialog = ProgressDialog.show(MainActivity.this, "Instalando parche", "Por favor, espere...", true);
String data_storage_root = getFilesDir().toString();
InputStream is= null;
OutputStream os = null;
File h = new File(data_storage_root+"/caca.txt");
File p = new File(data_storage_root+"/caca2.txt");
if (h.exists()) h.setWritable(true, true);
if (p.exists()) h.setWritable(true, true);
try {
is = getResources().getAssets().open("keypad/caca.txt");
is = getResources().getAssets().open("keypad/caca2.txt");
os = new FileOutputStream(data_storage_root+"/sec_key.kl");
os = new FileOutputStream(data_storage_root+"/sec_keypad.kl");
IOUtils.copy(is, os);
is.close();
os.flush();
os.close();
os = null;
} catch (IOException e) {
makeToast("Fallo al copiar");
finish();
}
h.setExecutable(false, true);
h.setReadable(true, true);
h.setWritable(false, true);
}
public void CopyFromAssetstosystem() throws TimeoutException, IOException, RootDeniedException {
CommandCapture command = new CommandCapture(0, "su", "mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system", "cp /data/data/com.fixer.gminipop/files/caca.txt /system", "mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");
RootTools.getShell(true).add(command).waitForFinish();
}
public void End() {
ClosePD();
AlertDialog();
}
public void AlertDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Es necesario reiniciar para que se apliquen los cambios. Desea hacerlo ahora?")
.setTitle("Instalacion satisfactoria!")
.setCancelable(false)
.setNegativeButton("Reiniciar mas tarde",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setPositiveButton("Reiniciar ahora",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// metodo que se debe implementar
try {
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
} catch (IOException e) {
}
// TODO Auto-generated method stub
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
AlertDialog alert = builder.create();
alert.show();
}
public void ClosePD() {
progressDialog.dismiss();
}
private static void copy(InputStream is, OutputStream os) {
// TODO Auto-generated method stub
}
public void makeToast(String msg) {
Context context = getApplicationContext();
CharSequence text = msg;
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
public void RootActions() {
}
}
Enviado desde mi GT-S5570I usando Tapatalk 2
Come on... It's easy!
Enviado desde mi GT-S5570I usando Tapatalk 2
Remove that "su" in the CommandCapture. You tell the library that you want to be root by calling getShell() with the parameter true. The parameter true tells RootTools to call su itself.
---------- Post added at 08:42 AM ---------- Previous post was at 08:40 AM ----------
DELETED
nikwen said:
Remove that "su" in the CommandCapture. You tell the library that you want to be root by calling getShell() with the parameter true. The parameter true tells RootTools to call su itself.
---------- Post added at 08:42 AM ---------- Previous post was at 08:40 AM ----------
DELETED
Click to expand...
Click to collapse
I don't understand you. Please, show me an example!
DannyGM16 said:
I don't understand you. Please, show me an example!
Click to expand...
Click to collapse
Change this
Code:
CommandCapture command = new CommandCapture(0, "su", "mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system", "cp /data/data/com.fixer.gminipop/files/caca.txt /system", "mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");
to
Code:
CommandCapture command = new CommandCapture(0, "mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system", "cp /data/data/com.fixer.gminipop/files/caca.txt /system", "mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");
nikwen said:
Change this
Code:
CommandCapture command = new CommandCapture(0, "su", "mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system", "cp /data/data/com.fixer.gminipop/files/caca.txt /system", "mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");
to
Code:
CommandCapture command = new CommandCapture(0, "mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system", "cp /data/data/com.fixer.gminipop/files/caca.txt /system", "mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system");
Click to expand...
Click to collapse
Thank's!
But I have another problem, I'm developing an app to copy files from assets to system. The code works, but the copy from /data/data/.. to /system/... take a long time and I don't know how to put a progress dialog. But this problem is strange, becouse the copy of the file is abot a minute after I close the app. I want to make a progress dialog in this time. Can you help me?? (I'm spanish, sorry for my english errors)
Notes:
1- Please, don't modify the function names, "reparar" corresponds a button
2- I know that I have a very dirty code, but only help in my problem, don't clean it
3- I wait for you to help me
Code:
public class MainActivity extends Activity {
ProgressDialog progress;
private static final String TAG = "Copy Example";
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if (RootTools.isRootAvailable()) {
} else {
finish();
}
}
public void reparar(View view) throws IOException, TimeoutException, RootDeniedException {
progress = ProgressDialog.show(this, "dialog title",
"dialog message", true);
copyfile1();
copyfile2();
copyfile1tosystem();
copyfile2tosystem();
End();
}
public void copyfile1() {
String data_storage_root = getApplicationContext().getFilesDir().toString();
InputStream is= null;
OutputStream os = null;
File h = new File(data_storage_root+"/file.format");
if (h.exists()) h.delete();
try {
is = getApplicationContext().getResources().getAssets().open("keypad/file.format");
os = new FileOutputStream(data_storage_root+"/file.format");
if (copy(is, os))
is.close();
os.flush();
os.close();
os = null;
Log.d(TAG, "success");
} catch (IOException e) {
Log.w(TAG, "failed copying certificate generic");
}
return;
}
public void copyfile2() {
String data_storage_root = getApplicationContext().getFilesDir().toString();
InputStream is= null;
OutputStream os = null;
File h = new File(data_storage_root+"/file2.format");
if (h.exists()) h.delete();
try {
is = getApplicationContext().getResources().getAssets().open("keypad/file2.format");
os = new FileOutputStream(data_storage_root+"/file2.format");
if (copy(is, os))
is.close();
os.flush();
os.close();
os = null;
} catch (IOException e) {
finish();
}
return;
}
public void copyfile1tosystem() throws IOException, TimeoutException, RootDeniedException {
CommandCapture command = new CommandCapture(0, "mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system", "cp /data/data/com.fixer.gminipop/files/sec_key.kl /system/usr/keylayout/file.format", "mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system");
RootTools.getShell(true).add(command);
}
public void copyfile2tosystem() throws IOException, TimeoutException, RootDeniedException {
CommandCapture command = new CommandCapture(0, "mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system", "cp /data/data/com.fixer.gminipop/files/sec_keypad.kl /system/usr/keylayout/file2.format", "mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system");
RootTools.getShell(true).add(command);
}
public void End() {
progress.dismiss();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Es necesario reiniciar")
.setTitle("Instalacion satisfactoria!")
.setCancelable(false)
.setNegativeButton("Hacerlo mas tarde",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setPositiveButton("Reiniciar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// metodo que se debe implementar
try {
ProcessBuilder pb = new ProcessBuilder(new String[] { "su", "-c", "/system/bin/reboot" });
java.lang.Process process = pb.start();
process.waitFor();
} catch (IOException e) {
}
// TODO Auto-generated method stub
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
AlertDialog alert = builder.create();
alert.show();
}
private boolean copy(InputStream in, OutputStream out){
try {
byte[] buffer = new byte[1024];
int read;
while (( read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
return true;
} catch (IOException e) {
Log.w(TAG, "fallo al copiar");
finish();
return false;
}
}
}
I've answered your last question in your other thread and I would prefer not to use this thread anymore. If RootTools works without calling "su" implicitly, even better as su is expensive call!
Thread closed.

[Library] Cmd library: Execute Your Java Codes With Root Access Privileges

Synopsis:
Have you ever wanted as root apps developer to use your favourite Java codes instead of bash/shell commands?
Have you grown tired of Runtime.getRuntime.exec("su") and ProcessBuilder("su").start()?
I did and still do, that's why I've been searching for a solution for my problem until I found out in AOSP source code that some of *.java files run with root access, tracking the way they execute them with root access led me to make this simple library.
Description:
Cmd library -short for Command- is an open source (licensed under Apache licence V2) that allows you to execute java commands with root access privileges by passing package name, full class name and whether your app is a system app or not in just two lines of codes.
For instance, suppose you want to flash a *.img recovery image, the first thing comes to your mind is this code:
Code:
busybox dd if=/path/to/recovery.img of=/path/to/recoveryPartition
lets say /sdcard/recovery.img is the file path and /dev/block/mmcblk0p12 is the partition (Samsung GALAXY Ace Plus GT-S7500)
Here is how to implement it:
Code:
...
Proccess proc = Runtime.getRuntime().exec("su");
OutputStream stream = proc.getOutputStream();
stream.write("busybox dd if=/sdcard/recovery.img of=/dev/block/mmcblk0p12".getBytes());
stream.flush();
...
Pretty simple isn't it, now suppose you don't know anything about bash codes, what will you do?
Let me answer this question:
1) Learn some bash.
2) Use Cmd library with java codes.
Here is the same implementaion with Cmd library:
Code:
...
JavaRoot root = JavaRoot.newInstance(getPackageName(), RootCommands.class.getName(), false);
root.execute("/sdcard/recovery.img", "/dev/block/mmcblk0p12")
...
And in RootCommands.java file (should not be an inner class):
Code:
package com.bassel.example;
import com.bassel.cmd.Command;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class Main extends Command
{
private byte[] buffer;
private File recovery, partition;
private FileInputStream in;
private FileOutputStream out;
//static main method implementation is a must
@Override
public static void main(String[] args)
{
//required to start
new Main().run(args);
}
//the begging just like onCreate
@Override
public void onRun()
{
if(argsCount() < 2) showUsage();
System.out.println(String.format("Flashing %s to %s", getArg(0), getArg(1)));
recovery = new File(nextArg());
partition = new File(nextArg());
buffer = new byte[1024 * 1024];
try
{
in = new FileInputStream(recovery);
out = new FileOutputStream(partition);
while(in.read(buffer) > 0)
{
out.write(buffer);
out.flush();
}
in.close();
out.close();
System.out.println("Flashed successfully!");
}
catch (Exception e)
{e.printStackTrace(System.err);}
}
//called upon calling showUsage()
@Override
public void onShowUsage()
{
System.err.println("Two args are needed!");
}
//called once an exception is caught
@Override
public void onExceptionCaught(Exception exception)
{
exception.printStackTrace(System.err);
}
}
Quite lengthy but sometimes we prefer using Java codes to bash ones, don't we?
Here is another example for listing /data files:
Code:
package com.bassel. example;
import java.io.File;
//Without extending Command.class
public class Main
{
@Override
public static void main(String[] args)
{
String[] files = new File("/data").list();
for(String file : files)
{
System.out.println(file);
}
}
}
Usage in depth:
Check root access:
Cmd.root();
No root:
Cmd.SH.ex(String command, String... args);
Cmd.SH.ex(String[] commands);
Cmd.SH.ex(List commands);
With root access:
Cmd.SU.ex(String command, String... args);
Cmd.SU.ex(String[] commands);
Cmd.SU.ex(List commands);
JavaRoot java = JavaRoot.newInstance(String packageName, String className, boolean isSystemApp);
java.execute(String... args);
java.executeInBackground(String... args);
All previous methods aside of the last one:
java.executeInBackground(String... args);
return an instance of type Output that has the following methods:
Code:
boolean success() //returns true if process exit value = 0 else false
String getString() //returns output in String format
String[] getArray() //returns output in String Array format
List getList() //returns output in String List format
int getExitValue() //returns process exit value
String toString() //returns process status and output in String format
Converting:
String string = ...;
String[] array = ...;
List list = ...;
String s1 = Convert.array2string(array);
String s2 = Convert.list2string(list);
String[] a1 = Convert.list2array(list);
String[] a2 = Convert.string2array(string);
List l1 = Convert.array2list(array);
List l2 = Convert.string2list(string);
Library GitHub link:
Cmd (licensed under Apache License, Version 2.0)
Examples:
Window Manipulator

Run su -c "command" process

I want to use su to launch a command and read its output.
I try this code:
Code:
String line;
Process cat=Runtime.getRuntime().exec("su -c \"cat /etc/media_codecs.xml\"");
BufferedReader catStream= new BufferedReader(new InputStreamReader(cat.getInputStream()));
BufferedReader catSerr= new BufferedReader(new InputStreamReader(cat.getErrorStream()));
cat.waitFor();
while((line=catSerr.readLine())!=null)
{
System.out.println(line);
}
while((line=catStream.readLine())!=null)
{
System.out.println(line);
}
If I manually insert this command in the adb shell it works but with this code the phone ask me for root permission and If I accept I can read only this string to the stderr:
tmp-mksh: cat /etc/media_codecs.xml: not found
And there is not stdout code.
Why?
Thanks,
regards
A993

[Q] External process with ProcessBuilder

I wrote a simple application that needs to run external programs as superuser. I run this piece of code in a periodic task: the code is contained in a Runnable that runs periodically by using a ScheduledThreadPoolExecutor. The code works well for a while, but after some times it stops to work randomly. To do that I used the following code. By debugging the application I found the problem is in the line Process process = builder.start();
I mean that when the problem happens the execution wait the return of this method forever.
Code:
//Code in run() Method of a class that implemnst Runnable:
ArrayList<String> results = new ArrayList<String>();
try {
ProcessBuilder builder = new ProcessBuilder("su");
builder.redirectErrorStream(true);
Process process = builder.start();
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
BufferedReader bRes = new BufferedReader(new InputStreamReader(
process.getInputStream()));
os.writeBytes("busybox ifconfig | busybox grep 'eth'; echo done_done\n"); //<-- this is my command for now
os.flush();
String r;
long curr = System.currentTimeMillis();
while ((r = bRes.readLine()).equals("done_done") == false){
results.add(r);
}
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e) {
//...
}
Any suggestions? I can't figure out what kind of problems produce this situation. I used this code in past without problems. Can the command line "busybox ifconfig | busybox grep 'eth'; echo done_done\n" not return and works forever? I don't think so..
Thank you, Nico

Categories

Resources