Is there an ADB push nautilus script out there?
That'll be handy, but i'm no scripting expert. I suspect it'll be bit tricky since adb is terminal only, I'm sure someone will have to figure out a way to pipe the output from terminal to GUI pop up dialog box to display progress bar, with success or failure message.
this one seem to work but no progress bar or success/fail message tho. YMMV
Code:
#/bin/sh
adb push $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS /sdcard
save this as adb_push.sh
be sure to set this file with permission:
Code:
chmod a+x adb_push.sh
think of this as rough draft, not perfect. Above code will push straight to sdcard. Suppose you could create few scripts like this..
ADB - Push to System APP
Code:
#/bin/sh
adb remount
adb push $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS /system/app
ADB - Install APK
Code:
#/bin/sh
adb install $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
EDIT: Forgot to mention this, it'll work only if you've already set path to Android's SDK tools folder in .bashrc
awesome, thanks! I'll test it in a minute
Simple scrip to push files to your android device.
Just put it in your Nautilus script dir (HOME/.gnome2/nautilus-scripts) and make it executable (chmod +x Push\ sdcard). also set path for ADB inside script (ADB=...)
I did something similar a while back for both Konqueror and Dolphin in KDE, but I realized, I just don't use a file manager since I prefer the command line instead. I had a working ADB zsh completion script, but somehow forgot to back it up before my previous hard drive failure.
https://code.google.com/p/send-to-android/
this is interesting
Hello, maybe here someone will help me
I'm writing a file manager app and I want to allow it for browsing with root permissions.
All I have so far is creation of a Process object using Runtime.exec("su"). Then I get output stream from it and write "ls" command. And here goes the question. How to read the output of the "ls"? Getting the input stream from the process gives me stdout of the "su" which is useless.
glodos said:
Hello, maybe here someone will help me
I'm writing a file manager app and I want to allow it for browsing with root permissions.
All I have so far is creation of a Process object using Runtime.exec("su"). Then I get output stream from it and write "ls" command. And here goes the question. How to read the output of the "ls"? Getting the input stream from the process gives me stdout of the "su" which is useless.
Click to expand...
Click to collapse
Use the -c option of su:
Code:
su -c 'ls -l /system/'
I think I'm closer, but still it doesn't work
I have this:
Code:
p = Runtime.getRuntime().exec("/system/bin/su -c 'ls -d -1 "+directory.getAbsolutePath()+"/*'");
So the command for a directory /data will be:
Code:
/system/bin/su -c 'ls -d -1 /data/*'
But it gives me:
Code:
W/su (13979): request rejected (0->0 'ls)
I have tried putting the command's parts into array but then system asks for su permission on every command. For ex. ls /data needs permission and ls /system needs another permission beacuse the command is different.
Not much I can think of to do about that. I had a similar issue once upon a time and I dealt with it by using a script that read its commands from a data file. I'd write the datafile to my program's designated directory (no special permissions required), then run a single command with su and that script would read the datafile to know what to do, otherwise, I had a ****load of su requests bothering the user.
You've got a point there, but making it work with a file manager, where the commands are related to user interaction would be very difficult. Anyway I will put it into my consideration.
I wonder how all these root explorers are made but none of the developers, which I asked so far, were so kind to give me some tips
glodos said:
You've got a point there, but making it work with a file manager, where the commands are related to user interaction would be very difficult. Anyway I will put it into my consideration.
I wonder how all these root explorers are made but none of the developers, which I asked so far, were so kind to give me some tips
Click to expand...
Click to collapse
Well, I suppose you could keep a process open to a shell with root permissions and once open, keep input and output pipes routed to it and send and receive commands as needed.
Gene Poole said:
Well, I suppose you could keep a process open to a shell with root permissions and once open, keep input and output pipes routed to it and send and receive commands as needed.
Click to expand...
Click to collapse
Well, that's what I've tried to do, but as I mentioned in the first post, output pipe gives me stdout of the su process which doesn't write any output (but "ls" does).
glodos said:
Well, that's what I've tried to do, but as I mentioned in the first post, output pipe gives me stdout of the su process which doesn't write any output (but "ls" does).
Click to expand...
Click to collapse
No, I don't think you're following me. Just run su -c 'sh' and it should run a shell and keep it open. From there, you create an input stream, output stream and possibly an error stream, then write commands like "ls -l /system\n" (the \n triggers the shell to execute it) to the output stream, then read the results form the input stream. You keep doing this as needed and when you're done just send "exit\n".
Oh, I understand now. I'll try it ASAP.
Edit:
It works now, but I have problems with stopping the loop. Here is my piece of code:
Code:
String[] cmd = new String[]{"su", "-c", "/system/bin/sh"};
console = Runtime.getRuntime().exec(cmd);
BufferedWriter stdin = new BufferedWriter(new OutputStreamWriter(console.getOutputStream()));
stdin.write("ls -d -1 "+directory.getAbsolutePath()+"/*\n");
BufferedReader stdout = new BufferedReader(new InputStreamReader(console.getInputStream()));
String read;
data1 = new String();
while((read=stdout.readLine())!=null){
data1+=read + "\n";
}
The problem is, that it hangs at some point on invocation of "stdout.readLine()". I have read that it waits for some data to come and it will never be null.
Furthermore if my ls command returns nothing (which can happen) it always hangs forever on readLine().
Anyway I'll try to do something with this. Maybe there is a workaround and reading will not block.
Thank you for your effort, it was really helpful.
glodos said:
The problem is, that it hangs at some point on invocation of "stdout.readLine()". I have read that it waits for some data to come and it will never be null.
Furthermore if my ls command returns nothing (which can happen) it always hangs forever on readLine().
Anyway I'll try to do something with this. Maybe there is a workaround and reading will not block.
Thank you for your effort, it was really helpful.
Click to expand...
Click to collapse
Sorry to ressurect such an old thread. I'd been having the same problem with reads blocking using BufferedReader, InputStream and other variants. Turns out BufferedReader has a ready() method which indicates whether a read() will block. This code works for me:
Code:
String outputStr;
BufferedReader reader = new BufferedReader(new InputStreamReader(suProcess.getInputStream()));
while (reader.ready()) {
outputStr += reader.readLine();
}
Hope it helps someone from the repeating the same frustrations. Heck I hope it helps me in the future in case I forget this
When I execute shell commands such as:
Code:
C:\android-sdk-windows\platform-tools>adb shell
# ls
ls
ls: not found
Can't seem to find the problem, all binaries/links are in /sbin and working correctly, for example:
Code:
> /sbin/ls
works fine
I'm trying to find settings in the boot.img ramdisk, but having no luck so far. Any ideas how to fix it? My device is an Xperia Ray.
Thanks
Update: I gave up trying to find out and just did a work around.
For some reason something is setting $PATH to /usr/bin:/bin, even though in init.rc:
Code:
export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
is set.
After spending ages messing around trying to find it/find a way of setting it back, I just ended up symlinking /sbin to /bin in the ramdisk/sbin/bootrec and repacking. It works, but if anyone could shed some light, it'd still be appreciated. Thanks.
Hi All,
I am writing a batch script to perform functions via ADB to set up our devices.
The device is rooted, and i can do the following via ABD:
adb root
adb remount
adb shell
sqlite3 /data/system/locksettings.db
sqlite3> update locksettings SET value='1' where name='lockscreen.disabled';
sqlite> .quit
There is not the issue so far, and this works to disable the screen lock from swipe to "none"
Here is the issue, I have created a batch file, which processes all the various commands I have, which works perfectly, the problem is i cannot execute that as one command I.E.
adb shell sqlite3 /data/system/locksettings.db update locksettings SET value='1' where name='lockscreen.disabled';
This fails, i have tried various syntax changes but i get and error of TO MANY OPTIONS FOR LOCKSETTINGS
any thoughts or solutions would be most appreciated.
Kind regards
Anthony Aveley
Greetings,
I have these commands I run from cmd :
Code:
adb shell settings put secure qs_tile_row 2
adb shell settings put secure qs_tile_column 5
adb shell settings put secure sysui_qqs_count 5
The thing is, that these do not survive a reboot, so I wanted to create a script that would run the shell commands on boot.
I created a file in init.d but I can't get a hold of the syntax to put these exact 3 commands.
Any help is appreciated.