1. Are you ready for the Galaxy S20? Here is everything we know so far!

shell command file extentions

Discussion in 'Android Lounge' started by Trogue, Sep 17, 2011.

  1. Trogue

    Trogue Lurker
    Thread Starter

    Hello i am new to android and this forum.i was wondering what is the file extention for running commands shells. eg .bat (windows) Is there a extention for it at all or do i have to enter them individualy in terminal editor.
     



    1. Download the Forums for Android™ app!


      Download

       
  2. El Presidente

    El Presidente Beware The Milky Pirate!
    VIP Member

    Welcome to AF! :)

    I'm sure you could do something via ADB if you had the Android SDK installed. Not my forte though but I'll see if any of the other guides can assist.
     
  3. Xyro

    Xyro 4 8 15 16 23 42
    Moderator

    I believe gscript can run them in the form of .sh files, although it's not something I know much about to be honest.
     
    El Presidente likes this.
  4. John Redcorn

    John Redcorn Android Enthusiast

    never done a script on android but on regular linux you don't have to have an extension, just have to chmod it as executable.
     
    El Presidente likes this.
  5. scary alien

    scary alien not really so scary
    Moderator

    Welcome to the AndroidForums, Trogue!

    Well, there are mime type file extensions (i.e., the files / programs associated with each file's extension suffix) that Android uses to associate things when you "reference" them (i.e., invoked in the proper context with the proper program).

    You can see this with something like Astro File Manager (free in the Market) by going to menu -> More -> Preferences -> Edit File Extensions.

    Now, what happens when you try to invoke/launch/run a particular file with its associated program I believe depends on whether or not you've installed a program that knows how to handle it (i.e., listens for system intents based on the given mime file type). You can see an example of this long-pressing a .txt file and seeing what programs show-up and are available to be launched with this .txt file type (its because the program has a compatible SEND mime type in its AndroidManifest.xml file).

    In addition to the excellent example that Xyro mentioned, Gscript / Gscript Lite, there is also a similar program called Script Manager. These guys know how to invoke a sh shell program and feed the commands listed in a given script file to the sh shell and re-display the results to the Android window.

    As far as launching things from a terminal emulator, well, that's just like a telnet client that you would see in Unix/Linux, so, all Unix-type rules apply (i.e., the #!<program path>-type references at the start of the script, etc.). The file must also be located in a non-SD card filesystem and its permission bits properly set if you are to execute it directly. Or, you'll have to invoke a shell (sh) and give it the name of the text file (.sh) containing your shell commands (i.e., "sh myscript.sh").

    You best bet might be to create your files in a text editor on your PC, then invoke them with Gscript or Script Manager, or directly from a terminal window on your phone. You'll also have to be aware that you are pretty limited in what you can do without being rooted--many of the most useful commands are not present unless you have a busybox utility installed.

    Cheers!
     
    El Presidente likes this.
  6. Trogue

    Trogue Lurker
    Thread Starter

    iv downloaded script manager because its free .sh seems to work on it
    Thanks for the help
     
  7. scary alien

    scary alien not really so scary
    Moderator

    Trogue,

    I should point-out that there is a free version of Gscript called Gscript Lite (https://market.android.com/details?id=nl.rogro.GScriptLite&feature=search_result).

    I've actually only used Gscript Lite...I don't have any experience with Script Manager, but after looking at the Market Description, it certainly does look interesting and very full-featured (I'll have to check it out).

    Cheers!
     
Loading...

Share This Page

Loading...