1. Download our Official Android App: Forums for Android!

shell command file extentions

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

  1. Trogue

    Trogue Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Sep 17, 2011

    Sep 17, 2011
    3
    0
    5
    Under your bed
    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.
     

    Advertisement

  2. El Presidente

    El Presidente Beware The Milky Pirate!
    VIP Member
    Rank:
    None
    Points:
    3,118
    Posts:
    32,107
    Joined:
    Jan 3, 2011

    Jan 3, 2011
    32,107
    24,092
    3,118
    Scotland
    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
    Rank:
     #17
    Points:
    1,433
    Posts:
    13,032
    Joined:
    Dec 1, 2009

    Dec 1, 2009
    13,032
    9,717
    1,433
    UK
    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
    Rank:
    None
    Points:
    53
    Posts:
    439
    Joined:
    May 9, 2011

    May 9, 2011
    439
    80
    53
    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
    Rank:
     #10
    Points:
    2,138
    Posts:
    22,319
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,319
    23,814
    2,138
    Male
    space alien ;)
    Indy
    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
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Sep 17, 2011

    Sep 17, 2011
    3
    0
    5
    Under your bed
    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
    Rank:
     #10
    Points:
    2,138
    Posts:
    22,319
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,319
    23,814
    2,138
    Male
    space alien ;)
    Indy
    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!
     

Share This Page

Loading...