ADB Screenshotting - HTC Aria Android Development

Found this binary that converts framebuffer dumps from /dev/graphics/fb0 into png files from the console.
http://code.google.com/p/android-fb2png/
Installed it, works pretty well. I made the following windows shell script to make screenshotting easier:
Code:
for /f "tokens=1-9 delims=/:. " %%a in ("%date% %time%") do (set stamp=%%d%%b%%c-%%e%%f%%g%%h)
adb shell /data/local/fb2png /sdcard/dcim/%stamp%.png
adb pull /sdcard/dcim/%stamp%.png %userprofile%\desktop\%stamp%.png
that whole %%d%%b%%c-%%e%%f%%g%%h madness formats the file name into YearMonthDay-HourMinuteSecondMillisecond.png so that they are always unique.
Hope someone finds this as useful as I did

combustiblemonkey said:
that whole %%d%%b%%c-%%e%%f%%g%%h madness formats the file name into YearMonthDay-HourMinuteSecondMillisecond.png so that they are always unique.
Hope someone finds this as useful as I did
Click to expand...
Click to collapse
Funny, I spent part of the day hacking together some date + batch foolishness.
Nice job. Should make documentation a lot easier.

Related

G1 Shell Commands Documentation

Greetings, as some of you may have noticed the commands from the shell on the G1 do not match up perfectly with the Linux command line. I've decided that we need some documentation on the shell commands on the G1 so that skilled and unskilled command line people can use their G1 like a pro.
I've set up a wiki that will serve this exact purpose at http://android.syntaxdeath.com/
Right now its mostly just a list of commands since I havn't had time to test them all out yet (and well half the commands just crash my phone anyway) but its a good start!
Finally, if you would like to contribute to the wiki, please follow the template that I posted at the bottom for standardization purposes (its loosely based off Man pages)
update: Running total of commands: 302
I would imagine what commands are available depends to some degree on what OS distribution you're using? Differentiating between internal (busybox) and external commands would also be useful.
/Mats
very cool..
Only trick I've found (as I haven't gotten to mess with it much), is that radiooptions 8 [somenumber] will dial [somenumber]
Craftkiller said:
Greetings, as some of you may have noticed the commands from the shell on the G1 do not match up perfectly with the Linux command line. I've decided that we need some documentation on the shell commands on the G1 so that skilled and unskilled command line people can use their G1 like a pro.
I've set up a wiki that will serve this exact purpose at http://android.syntaxdeath.com/
Right now its mostly just a list of commands since I havn't had time to test them all out yet (and well half the commands just crash my phone anyway) but its a good start!
Finally, if you would like to contribute to the wiki, please follow the template that I posted at the bottom for standardization purposes (its loosely based off Man pages)
Click to expand...
Click to collapse
would it be easier to setup the wiki info right here on XDA?
http://wiki.xda-developers.com/index.php?pagename=HTC_Dream
just might help keep the information together in one place?
I would imagine what commands are available depends to some degree on what OS distribution you're using? Differentiating between internal (busybox) and external commands would also be useful.
Click to expand...
Click to collapse
That is true, right now I am running the most recent version of JF so I based it off that... as for separating them, its a good idea, but I'd like to hold off till I finish documenting more commands b4 I try to do that stuff.
very cool..
Only trick I've found (as I haven't gotten to mess with it much), is that radiooptions 8 [somenumber] will dial [somenumber]
Click to expand...
Click to collapse
Awesome, I'll document radiooptions next
would it be easier to setup the wiki info right here on XDA?
http://wiki.xda-developers.com/index...name=HTC_Dream
just might help keep the information together in one place?
Click to expand...
Click to collapse
That could work also. I'm just a newbie to this whole site so I figured I shouldn't start touching whats already great here. I imagine it would be extremely easy to copy this stuff over to that wiki or we could just provide a link... either way, I'll let the forum demigods decide since right now it might appear as spam since so few commands are documented.
this is a great thread, i had planned on doing this but never got around to it, if i can find my printout i have many of the commands already documented. never got radio options to work, but i ran it through the adb shell, will give the onboard terminal a run through later. as most of you know the commands available can be found by typing
ls /system/bin /system/xbin /system/xbin/bb
that will tell you what commands you can use. i'll have more later when i get to my comp.
HAPPY ST. PAT'S
tubaking182 said:
this is a great thread, i had planned on doing this but never got around to it, if i can find my printout i have many of the commands already documented. never got radio options to work, but i ran it through the adb shell, will give the onboard terminal a run through later. as most of you know the commands available can be found by typing
ls /system/bin /system/xbin /system/xbin/bb
that will tell you what commands you can use. i'll have more later when i get to my comp.
HAPPY ST. PAT'S
Click to expand...
Click to collapse
Oh wow, I didn't even bother to check xbin and xbin/bb.... I'll add these commands to the list!
btw on JF using terminal emulator I was able to use radiooptions to start a call
Ok, I've added the new commands to the list bringing the total to 302 commands.... and i've only got like 6 documented so far... =(
sounds good, i am on my way over to your page to see what i can help with
edit: added several commands to the page, will add more in an hour or so
haha thank you! I was about to install ubuntu so I could do a nandroid backup on my phone b4 testing out wipe but it seems you've already done the dangerous part first! much appreciated =)
you can do a nandroid backup and flash in windows, someone here had the correct sutup for windows somewhere, but i don't know where it's at since i use ubuntu. the only reason i even tried the command was so that i could document a few things for myself, i had a piece of paper somewhere that i can't find now where i had written out all the commands and highlighted them according to danger for n00bs and also had what they did, or at least a good portion of them. wipe is dangerous for n00bs and so i will only suggest it in the most DIRE emergency cases, i had to do it cause my phone died and i was a n00b on this phone and decided that it would be easier to wipe it than try to find the correct stuff to get it back to factory settings. i discovered it works well for those having issues booting or other such. and that command is one of the many reasons to keep a copy of the latest JF rom on your SD card. going back to add a few more now
perhaps it would be a good idea to sort the commands by the directory theyre in on the wiki page.
that was actually already on my list of things to do, i will probably get it tomorrow sometime unless someone beats me to it
the $PATH var should help with catching some of the more obscure ones...
$ echo $PATH
/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin

Terminal/Script/ADB Cheat Sheet

I made this for my own reference and would like some experienced users to critique it (please don't laugh) and help me add to it. This is a first draft replacing the "napkin" I've got tucked under my keyboard. Specifically simple for newbes like myself to just help us get started with Terminal, Scripting, ADB and have a command reference to follow.
Please chim in on the ADB section which I know needs some serious help. I have almost no experience with ADB but seek to learn and document more so its useful. Or if something already exists like this but way better please point me to it so I can take from it or use it to replace this.
Thanks in advance!
Edit1: Redline1, change to:
chmod octal...10 columns: 1 Type, 9 Permissions
Nice start.
Some comments from top to bottom:
You don't need semicolons after each line. Only if you want to write more than one command on the same line - e.g. "if some condition; then".
For the directory commands (cd, mkdir, ...), you can type directories with leading "/" if you want to specify the complete path starting from root, and without leading "/" to refer to subdirectories of the current directory. ".." is the parent directory of the current directory.
"which" scans your $PATH for the command you give it, so especially if it exists multiple times it shows you "which" will get run if you type it without specifying a path. It has nothing to do with directories.
The permission groups are usually called "u=user", "g=group" and "o=other" (not "everyone else)". And "s---------" is a socket, not a binary - the rest is correct. Read all you wanted to know about the output of ls and much more here: http://www.gnu.org/software/coreuti...ion-is-listed.html#What-information-is-listed
You confused "logwrapper" with "logcat". You use "logcat" to display the log and "logwrapper" to redirect the output of something in your script to logcat.
"sh script.sh" will execute a script even if it doesn't have the "executable" permission set. Use chmod 7xx to make it executable directly without "sh".
"adb command" doesn't exist - to run a single command, you need to say "adb shell xxx".
"adb fastboot" also doesn't exist, at least on my adb.
Some general tips:
Many or all commands in busybox have built-in help if you invoke them with "--help". Also adb shows a small manual if you invoke it without parameters.
You can use most basic reference material for Linux, e.g. guides about shell scripting. It's 95% the same on Android.
Always be very careful when running commands as root - the system assumes you know what you are doing. There is no safety net. For example, "rm -rf" will happily wipe your entire device (if mounted writable) if you add a space between the following "/" and the rest of the path.
Thanks oodels for the feedback and corrections. I will update and rev the document based on this feedback when I get the time.
Also thanks for always being the one who takes the time to reply in detail to my threads, give me guidance, and inspire me to learn more about the discussion topic while NEVER making me feel like I have asked a dumb question or am the newbe I am. I had a college professor that reminds me of you who told me the only dumb question I could ask was the one I didn't ask. I appreciate that more than I can express. You are a plethora of knowledge and a master instructor with a winning humble and tackful approach to education and inspiration; a rare gem.
_that said:
Always be very careful when running commands as root - the system assumes you know what you are doing. There is no safety net. For example, "rm -rf" will happily wipe your entire device (if mounted writable) if you add a space between the following "/" and the rest of the path.
Click to expand...
Click to collapse
Thanks for _that tip. Knowing this now I think I will remove that example from the newbe guide as someone could easily mistype it, add a space after /, and wipe their device from the root down. I will also add the -i option to the command(s) that are dangerous, requiring user intervention (permission) to proceed with the command as a newbe safety factor.

[LIB] Java ADB Library (AdbLib)

Overview
About a month ago I got the urge to do some reverse engineering of ADB so that I could write an Android app that would be able to talk to devices the same way that the adb command-line tool distributed with the Android SDK does (without requiring root!).
The app that came about from this work has been on the Play Store about a month: https://play.google.com/store/apps/details?id=com.cgutman.androidremotedebugger
I had planned to do an open-source release of the library that I wrote for the app, but hadn't found the time to tidy up the code until recently. So today is my official announcement of the open-source release of my ADB work.
TL;DR full sources and detailed JavaDoc are here: https://github.com/cgutman/AdbLib
Functionality
AdbLib implements a connection object (AdbConnection) that sits atop a standard Java Socket class which it uses as the underlying transport for the ADB connection and all streams operating over it. The AdbConnection object contains methods for the creation of AdbStreams which represent the underlying data streams of ADB. AdbConnection also maintains the connection thread responsible for processing and responding to packets from the target device.
The AdbConnection object has an associated AdbCrypto object which abstracts the 2048-bit RSA key authentication used on Android 4.2.2 and later. AdbCrypto also has the capability of saving and loading key pairs, along with generating a fresh key pair. AdbCrypto requires an implementation the AdbBase64 interface which does the conversion of the RSA public key to a Base-64 encoded string that is transmitted to the 4.2.2+ device the first time it connects.
There's also low level AdbProtocol class which has many useful definitions and functions for receiving, validating, and generating ADB packets. This class's methods and fields are used by AdbConnection for packet processing and generation.
Conclusion
Hopefully you guys can do something cool with this library. It's under the BSD license so there shouldn't be any problem getting it included in any projects. I'd be happy to help with any bugs found or provide assistance integrating the library into projects. I also accept patches/pull requests
I've also published the Wireshark dissector I wrote to analyze the ADB protocol: https://github.com/cgutman/wireshark-adb-dissector
@cgutman thanks for this. I am examining how I can integrate this into CASUAL. It would be good for keeping the ADB process count low.
Would you be kind enough to document the flow here? I'm reading the code and I'm 1/2 way getting it, but I want a solid plan before I do a full-scale integration. Do you think you can do a flow of some sort?
Here's how I would be interested in using this library, from the desktop side. Would I hit any limitations here?
adb detect-device loop on port 5555
adb devices -- get number of devices detected
adb push -- fileinputstream from local file to /sdcard/
adb reboot recovery
adb wait-for-recovery
adb shell "echo foo>/data/cache/bar"
adb shell killall recovery
adb reboot
adb wait-for-device
It would be really neat to be able to contribute some things to this project and if this has basic functionality to be able to perform the above from the desktop side, I would be interested in generating several helper methods/classes which will act more familiar to those who are used to the command-line binary. I would also add features not found in command line like adb wait-for-any.
AdamOutler said:
@cgutman thanks for this. I am examining how I can integrate this into CASUAL. It would be good for keeping the ADB process count low.
Would you be kind enough to document the flow here? I'm reading the code and I'm 1/2 way getting it, but I want a solid plan before I do a full-scale integration. Do you think you can do a flow of some sort?
Here's how I would be interested in using this library, from the desktop side. Would I hit any limitations here?
adb detect-device loop on port 5555
adb devices -- get number of devices detected
adb push -- fileinputstream from local file to /sdcard/
adb reboot recovery
adb wait-for-recovery
adb shell "echo foo>/data/cache/bar"
adb shell killall recovery
adb reboot
adb wait-for-device
It would be really neat to be able to contribute some things to this project and if this has basic functionality to be able to perform the above from the desktop side, I would be interested in generating several helper methods/classes which will act more familiar to those who are used to the command-line binary. I would also add features not found in command line like adb wait-for-any.
Click to expand...
Click to collapse
already sounds like this could become very useful, an option to pull partitions from the device would be nice aswell!
ricky310711 said:
already sounds like this could become very useful, an option to pull partitions from the device would be nice aswell!
Click to expand...
Click to collapse
I've already got that option in CASUAL. Download any CASUAL from last night on, and you can use CASUAL.jar --execute "$PULL /dev/block/whatever, local file". The $FLASH command works the same, but it requires that you invert the args. It establishes a direct connection via TCP over USB and flashes the partition.
Will definayltely check it out, any chance of autodetection in the future?
For example umm
$pull boot
Autodetects mmcbl0p5?
Or is it just something we are gonna have to live with?
Sent from my GT-I9300 using xda app-developers app
ricky310711 said:
Will definayltely check it out, any chance of autodetection in the future?
For example umm
$pull boot
Autodetects mmcbl0p5?
Or is it just something we are gonna have to live with?
Sent from my GT-I9300 using xda app-developers app
Click to expand...
Click to collapse
That would be another feature all together... I can make that happen on newer devices. But this method WILL require root access of some kind on the device. Its really intended for flashing a recovery as part of a root exploit and making a backup of said recovery.
That would be great, I know this can be done on a rooted phone with pushing a utility to xbin or sbin and using shell to copy the boot.img to sdcard then pulling it?
Sent from my GT-I9300 using xda app-developers app
AdamOutler said:
@cgutman thanks for this. I am examining how I can integrate this into CASUAL. It would be good for keeping the ADB process count low.
Would you be kind enough to document the flow here? I'm reading the code and I'm 1/2 way getting it, but I want a solid plan before I do a full-scale integration. Do you think you can do a flow of some sort?
Here's how I would be interested in using this library, from the desktop side. Would I hit any limitations here?
adb detect-device loop on port 5555
adb devices -- get number of devices detected
adb push -- fileinputstream from local file to /sdcard/
adb reboot recovery
adb wait-for-recovery
adb shell "echo foo>/data/cache/bar"
adb shell killall recovery
adb reboot
adb wait-for-device
It would be really neat to be able to contribute some things to this project and if this has basic functionality to be able to perform the above from the desktop side, I would be interested in generating several helper methods/classes which will act more familiar to those who are used to the command-line binary. I would also add features not found in command line like adb wait-for-any.
Click to expand...
Click to collapse
AdbLib is a low-level abstraction of an ADB connection and its associated streams. It might not be exactly what you're looking for here. It's not really meant to be used as a direct replacement for the full adb command line client, since for one, it only handles ADB devices over the network.
There's no concept of detecting devices since connections are driven by you specifying a target to connect to. Conceivable you could push files with AdbLib (since it's just pushing data over a stream) but I haven't analyzed that protocol enough to know how it expects the file data to be sent.
Similarly, some of the special adb commands like "reboot" and "reboot recovery" should theoretically just be streams too, but I haven't analyzed the way the protocol deals with those commands.
The shell commands should be simple to send over AdbLib (since that's what it was originally designed for). To do this, you create a socket connected to your ADB target and pass it to AdbConnection.create() with an AdbCrypto object that contains a key pair that was either newly generated or loaded from a file. You then cal AdbConnection.connect() to begin the connection handshake process. When that returns, the handshake is finished. You can call AdbConnection.open("shell: killall recovery") and that will create a stream connected to the killall process (so you can send and receive output via stdin, stdout, and stderr). When the process terminates, your stream will close.
Sorry for reviving this old thread, but if anybody is interested in using AdbLib library, it's now available on maven central repo. It is slightly modified version of the library, but API hasn't changed much.
I'm reviving this thread once again
I used this adb library to create a Tasker Plugin!
https://play.google.com/store/apps/details?id=com.ADBPlugin
Please have a look
@cgutman Just a quick question. How do you send the ctrl+c from your app using this library? I can't seem to find it

A few command line utilities for RT

So not to clutter up an 'apps' list, I am putting together pieces to enable my surface rt to have more functionality available for on device scripting and a put together a few utilities to fill some areas I think (?) were missing. I might use these from scripts, nodejs, powershell or anywhere else I might launch processes.
So for starters I made :
csnotify - A utility to simulate the toast notification banners (like what you see for weather or new mail alerts). Unfortunately the api used to actual system notifications are c++ sdk binaries which i can't use, so this is as close a clone as i could make. The options are many and explained in a readme file in the zip.
naudiocon - a simple console mp3 file player which i might use for sound effects but it plays a song just as well. There are many pieces to the open source NAudio library which could be useful for future audio media players.
wget - a simple way to download a file from a url via command line. not a true clone of wget but you can enter wget {url} or wget {url} newfilename. run without any params to see that usage syntax.
cryptocli - a simple command line file encryption and hashing utility. Possibly useful for email or sending between computers which has this utility installed. like most ports this runs on arm or intel windows.
speak - a simple text to speech utility to read text either from command line itself or from file specified in command line.
wscon - command line web server. spin up server on -p port and -d directory from command line or put shortcut to this app in 'shell:sendto' to send a -directory- to it (using default port or 8080)
The files are already signed, but if you download directly to your device you should probably right click the downloaded zip(s) and 'unblock' them on the file 'properties' page. This seems to be required when downloading to NTFS partitions, as it will flag the download as 'coming from an unsafe domain' (internet). If you save the file to non-ntfs sdcard/usb/nas you should not have to unblock.
nazoraios said:
So not to clutter up an 'apps' list, I am putting together pieces to enable my surface rt to have more functionality available for on device scripting and a put together a few utilities to fill some areas I think (?) were missing. I might use these from scripts, nodejs, powershell or anywhere else I might launch processes.
So for starters I made :
csnotify - A utility to simulate the toast notification banners (like what you see for weather or new mail alerts). Unfortunately the api used to actual system notifications are c++ sdk binaries which i can't use, so this is as close a clone as i could make. The options are many and explained in a readme file in the zip.
naudiocon - a simple console mp3 file player which i might use for sound effects but it plays a song just as well. There are many pieces to the open source NAudio library which could be useful for future audio media players.
wget - a simple way to download a file from a url via command line. not a true clone of wget but you can enter wget {url} or wget {url} newfilename. run without any params to see that usage syntax.
cryptocli - a simple command line file encryption utility. Possibly useful for email or sending between computers which has this utility installed. like most ports this runs on arm or intel windows.
The files are already signed, but if you download directly to your device you should probably right click the downloaded zip(s) and 'unblock' them on the file 'properties' page. This seems to be required when downloading to NTFS partitions, as it will flag the download as 'coming from an unsafe domain' (internet). If you save the file to non-ntfs sdcard/usb/nas you should not have to unblock.
Click to expand...
Click to collapse
Thanks definitely going to be using wget. If only we could make a port of bash...
Sent from my SGH-M919 using XDA Free mobile app
Qiangong2 said:
Thanks definitely going to be using wget. If only we could make a port of bash...
Sent from my SGH-M919 using XDA Free mobile app
Click to expand...
Click to collapse
Bash shell would be great, git-bash would be even better.
There's a lot of c++ projects that I haven't been able to set up visual studio to compile for arm. vs2013 and 2015 haven't been playing very well so far, I think mamaich successfully did some arm ports with vs2012. Then there's Win10 iot efforts which Microsoft may be more inclined to support officially. They seem to support console c++ apps on win10arm using vs2015 here :
http://ms-iot.github.io/content/en-US/win10/samples/ConsoleApp.htm
I have not even begun trying to set up MinGW/Cygwin which I believe is the toolchain required for cross compiling Linux source projects for win/arm.
nazoraios said:
Bash shell would be great, git-bash would be even better.
There's a lot of c++ projects that I haven't been able to set up visual studio to compile for arm. vs2013 and 2015 haven't been playing very well so far, I think mamaich successfully did some arm ports with vs2012. Then there's Win10 iot efforts which Microsoft may be more inclined to support officially. They seem to support console c++ apps on win10arm using vs2015 here :
http://ms-iot.github.io/content/en-US/win10/samples/ConsoleApp.htm
I have not even begun trying to set up MinGW/Cygwin which I believe is the toolchain required for cross compiling Linux source projects for win/arm.
Click to expand...
Click to collapse
Windows RT was probably coded using vs2012, that's why it's better to use vs2012. Also, Microsoft removed and changed lots of stuff in vs2013 and even more in vs2015 from vs2012. Vs2013 and 15 probably don't have the right commands built in
Sent from my SGH-M919 using XDA Free mobile app
hey i made batch file with sample commands for csnotify
p.s save the file with .bat
p.p.s i seek a bug, the -m text dont support long words
roxas22 said:
hey i made batch file with sample commands for csnotify
p.s save the file with .bat
p.p.s i seek a bug, the -m text dont support long words
Click to expand...
Click to collapse
since your parameter has spaces in it you should wrap it in quotes like :
Code:
csnotify -t "hi xda!!!" -m "i love xda!!!"
nazoraios said:
since your parameter has spaces in it you should wrap it in quotes like :
Code:
csnotify -t "hi xda!!!" -m "i love xda!!!"
Click to expand...
Click to collapse
Thanks, i have some problems with usising batch language
Well I finally figured out how to tap into speech libraries on windows rt, so I created a command line utility.
You can use it to speak some generic text by using this command line :
Code:
speak -t "hello world this is text to speech on windows rt"
Or you can pass in a filename :
Code:
speak "c:\some path to\filename.txt"
Or you can type "shell:sendto" into the address bar of windows explorer and create a shortcut to speak.exe in there and then you can then send text files to it and it will read them.
File should be attached for download.
I added a command line version of simplewebserver, which is called 'wscon' (webserver console).
bundled readme :
This is a console/parameter based version using much of the same code as SimpleWebServer program, but created for command line/script invocation.
The use case for this app is when you frequently change hosting directories and just want to spin up a server on some port and directory.
You can specify port and directory with -p and -d command line options or you can create a shortcut to this wscon program in your shell:sendto folder and right click a directory and 'send to' it.
If you use sendto it will use the default port set in wscon_settings.xml file, which is automatically generated in same folder as executable. Once this file exists you can override the default port of 8080 to be something else if you want.
If you launch from console with just -d option it will use default port in wscon_settings.xml also.
By default this application serves up only to local machine (localhost), if you run it as admin it will be visible to other computers (provided firewall allows).
Click to expand...
Click to collapse

sudo in Android

I am looking for advice on how to define a "sudo" command, given that I have a working "su" command.
I have been getting away with
Code:
alias sudo='su -c '
but recently got a silly error message that makes me think I need more than one backward-slash to escape the asterisk I am trying to pass to "find" in an "-iname" option. (And leaves me wondering what I've been doing this last year when I thought it was working as expected.)
@Cruzy12100 described using "sudo". I wanted (and still want) him to explain in detail how he comes to have an "sudo" command available.
To invoke SU command the synthax is
Code:
su -c '<YOUR-COMMAND-HERE>'
Note that the <YOUR-COMMAND-HERE> must be enclosed with single quotes.
Currently, using the "su" provided by Magisk, I get away with the alias I described.
@jcmm11 advised me to use
Code:
alias sudo='su -c "[email protected]"'
I remember on an earlier Android, with a different "su", I had to enclose the argument in quotes, which then led to the nightmare of trying to multiply backward slashes when trying to re-issue a command, this time as an argument to "su". On that tablet, I just gave up and switched to "root mode" when I needed to.
When I use "su" in Linux, I don't have to wrap the command in quotes -- it's easy to recall a command, put sudo in front of it, and execute it. (I'm mostly using "ls" and "find", so there's usually no risk of damaging anything.)
I just tried playing with the "[email protected]" construct. In my tests, with
Code:
alias xxx='echo fore "[email protected]" aft"'
The "[email protected]" doesn't seem to do anything:
Code:
xxx asdf
produces
fore aft asdf
Maybe the suggestion was targeting a different shell.
J.Michael said:
Currently, using the "su" provided by Magisk, I get away with the alias I described.
@jcmm11 advised me to use
Code:
alias sudo='su -c "[email protected]"'
I remember on an earlier Android, with a different "su", I had to enclose the argument in quotes, which then led to the nightmare of trying to multiply backward slashes when trying to re-issue a command, this time as an argument to "su". On that tablet, I just gave up and switched to "root mode" when I needed to.
When I use "su" in Linux, I don't have to wrap the command in quotes -- it's easy to recall a command, put sudo in front of it, and execute it. (I'm mostly using "ls" and "find", so there's usually no risk of damaging anything.)
I just tried playing with the "[email protected]" construct. In my tests, with
Code:
alias xxx='echo fore "[email protected]" aft"'
The "[email protected]" doesn't seem to do anything:
Code:
xxx asdf
produces
fore aft asdf
Maybe the suggestion was targeting a different shell.
Click to expand...
Click to collapse
Couple of points, prefaced by the fact that I can't currently test or verify anything.
First of all, about [email protected] Specifically from the documentation for mksh (which is Android's default shell):
Same as $*, unless it is used inside double quotes, in whichcase a separate word is generated for each positional parameter.If there are no positional parameters, no word is generated. [email protected]can be used to access arguments, verbatim, without losing NULLarguments or splitting arguments with spaces.
Magisk switched to ensuring that any startup scripts etc use Magisk's BusyBox commands on order to ensure consistency. I don't however think that su changed the shell to the BusyBox shell (which is ash, the Almquist shell), that would actually be bad for consistency.
For a test try something like:
alias sudo='su -c "[email protected]"'
sudo echo test
and see what happens. It should just return "test".
Personally I've never cared for sudo. I've always just preferred to use su, both on Android and Linux. But that's another discussion entirely.
jcmm11 said:
...
For a test try something like:
alias sudo='su -c "[email protected]"'
sudo echo test
and see what happens. It should just return "test".
...
Click to expand...
Click to collapse
It printed "test"
My problem is that I do not see any evidence that '"[email protected]"' is expanding to anything: I get the same result with or without that construct.
Code:
alias xxx='echo a "[email protected]" b'
alias yyy='echo a b '
I think I am using "sh" as a shell, both in my normal terminal, and when I use "su". (/bin/sh is not a link to toybox, it is a 400KB file)

Categories

Resources