Well the title say it, but the issue is this:
I have a .sh file with a command su touch /sdcard/test.txt
to see if it works. But I don't know how to include it when the user install the app. How could I add it? I thought about using something like:
su
touch /sdcard/folder/path/test.sh
vi /sdcard/folder/path/test.sh
and there create the .sh file, but I don't know how to send the esc
key to be able to :wq
I know how to execute the file, and yes my phone is rooted. I just need to know how to include it when the apk is installed and/or how to send the esc
key to finish the vi
command.
Thanks
EDIT: I created a .sh
file called test.sh
and I created a app which one is for root users. The test.sh
file only have touch /sdcard/test.txt
just to see if my java code works. I created a simple app with one button and inside that button click I have this:
test.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
try
{
Process proc = Runtime.getRuntime().exec(new String[] {"su","-c","sh ./path where .sh will be/test.sh"});
proc.waitFor();
}
catch (Exception ex)
{
String TAG = null;
Log.i(TAG, "Doesn't work", ex);
}
}
});
BUT I don't know how to or where I have to add my test.sh
file so when the user install my app the file is there. I tried including
Process proc = Runtime.getRuntime().exec(new String[] {"su","-c","touch /sdcard/prueba.sh ; vi /sdcard/prubea.sh ; ****Don't know how to edit, use ESC key and :wq****});
proc.waitFor();
Now when I click my button the app keeps running waiting for me to end the vi
command, but I don't know how to since I will have to press esc
to be able to :wq
... Hope this makes it clear