See the top rated post in this thread. Click here

Results 1 to 13 of 13
  1. #1
    Senior Member
    Join Date
    May 2011
    Posts
    245
    Blog Entries
    3

    Device(s)
    Droidx, Xoom and Comcast MIFI Hotspot

    Android Shell questions

    What is the android equivalent of clear or cls?
    What editor is available at the $ prompt?
    I am using the android terminal emulator and I would like to be able to clear the screen and I would also like to be able to create and edit a text file.

  2. #2
    Are you rooted? I don't really remember, but I don't think much is available on unrooted devices. Once you root, you will have Busybox which gives you a ton of terminal tools, including the vi editor and the clear command, and you can also install better terminals. Unrooted, you should be able to create a text file on the sdcard but I don't know if there are any terminal editors available. You could edit it with a file manager, but that probably doesn't help much.



  3. #3

  4. #4
    Senior Member
    Join Date
    May 2011
    Posts
    245
    Blog Entries
    3

    Device(s)
    Droidx, Xoom and Comcast MIFI Hotspot

    Original Poster
    Thanks for the assist. The File Editor in the File Manager would work. Do you know how to execute it from the $ prompt?
    Not Rooted yet. Want to discover the basics first. :-) Do you know how do a recursive search using LS?



  5. #5
    "ls -R" will recursively list all files in the current directory or "ls -R /some/other/directory" to recursively list files somewhere else.

    You can't usually launch an app from the command line, Android just doesn't work that way. The only way it can be done is through an "intent" using the "am" command. Intents are a way to tell the system to do something and they are complicated enough to drive you crazy. They are usually used to turn on/off a certain feature of an app and they have to be included by the developer of the app you want to run. It's often hard to find an app with a certain intent. The file manager you're using may work, but you'd probably have to root around it's forum to find out. I did find a text editor with an intent that can open a file.

    Go to the Market and download Text Edit by Paul Mach. The command to open a file with it is "am start -a android.intent.action.VIEW -n org.paulmach.textedit/.pmTextEdit -d /sdcard/YOURFILE" where "/sdcard/YOURFILE" is the name of the file you want to edit. As intents go, that one is actually fairly simple.

    You don't want to type that every time so here's what I would do. Make a text file on the sdcard named "edit" (or anything you want to call it). Put this in the file:

    am start -a android.intent.action.VIEW -n org.paulmach.textedit/.pmTextEdit -d /sdcard/${1}

    Now that will act like a script and instead of looking for /sdcard/YOURFILE, it looks for an argument. To run it, you have to execute it with the shell and give it a file to open as an argument. So type "sh /sdcard/edit /sdcard/SOMEFILE" at the prompt. That will tell the shell (sh) to execute the contents of /sdcard/edit and /sdcard/SOMEFILE becomes the argument for that, so the app will open with SOMEFILE loaded and ready to be edited.


    That sounds strange, but the system looks in /system/bin and a couple of other places for programs and scripts, but unless you're rooted, /system is read-only so you can't put anything there for the system to find it. You have to put them on the sdcard and type "sh /sdcard/yourscript" to run them. If you decide to root, you can make a real script like this:

    #! /system/bin/sh
    am start -a android.intent.action.VIEW -n org.paulmach.textedit/.pmTextEdit -d /sdcard/${1}

    then put it in /system/bin and run it like any normal shell command by just typing it's name and a file to open like "edit /sdcard/foo.txt".

    Uh, did any of that make sense?


    1 members found this post helpful.

  6. #6
    Senior Member
    Join Date
    May 2011
    Posts
    245
    Blog Entries
    3

    Device(s)
    Droidx, Xoom and Comcast MIFI Hotspot

    Original Poster
    What an excellent response! Thank you so much. Is there any documentation of the commands available on an unrooted Honeycomb device?



  7. #7
    Senior Member
    Join Date
    May 2011
    Posts
    245
    Blog Entries
    3

    Device(s)
    Droidx, Xoom and Comcast MIFI Hotspot

    Original Poster
    Just to fecap
    Sh /sdcard/edit /sdcard/testfile fails with "Unable to ope Attachment"
    Whar works is
    Sh /sdcard/edit testfile
    So that does, indeed, give me a text editor executable from the terminal.Thank you again



  8. #8
    Quote Originally Posted by john test View Post
    What an excellent response! Thank you so much. Is there any documentation of the commands available on an unrooted Honeycomb device?
    Sorry I'm so slow. There's not really any documentation, but you should be able to see what's available by running the commands "ls /system/bin" and possibly "ls /system/bin." That will list what's in the main directory where the shell programs reside. xbin may be for rooted phones, I'm not sure. There will be some Android command line programs with funky names in there too.



  9. #9
    Senior Member
    Join Date
    May 2011
    Posts
    245
    Blog Entries
    3

    Device(s)
    Droidx, Xoom and Comcast MIFI Hotspot

    Original Poster
    Yea I can see the commands there and some will display useage and options but most don't.



  10. #10
    Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    3

    Device(s)
    Samsung Galaxy NOTE
    Thans a lot!!



  11. #11
    Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    3

    Device(s)
    Samsung Galaxy NOTE
    any "man" equivalent for android ??
    I thought initially that the kernel is linux type, so the shell would be similar... but.. its quite different and doesn't support much without busy-box..



  12. #12
    Senior Member
    Join Date
    May 2011
    Posts
    245
    Blog Entries
    3

    Device(s)
    Droidx, Xoom and Comcast MIFI Hotspot

    Original Poster
    Haven't found anything yet. If I do I will post it here.



  13. #13
    Member
    Join Date
    Feb 2012
    Posts
    13

    Device(s)
    samsung galaxy y young

    download

    where to download android elf executables



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •