1. Check out our companion app, Forums for Android! Download from Google Play

Support Terminal Emulator - calling a script

Discussion in 'Android Devices' started by mhlsilverdale, May 31, 2012.

  1. mhlsilverdale

    mhlsilverdale Well-Known Member
    Thread Starter
    23

    May 14, 2012
    96
    25
    23
    Pacific Northwest
    I'm trying to keep my log file growth in check on my triumph.
    I have a text file I can paste into Terminal Emulator that will delete log files in /data; I want to be able to load this file from terminal emulator. I can get it to load, but it seems lost; (e.g., can't mount, can't change directories...) Can some one tell me how to load a file into terminal emulator that will run like when I paste the same commands into it? Basically, I'm trying to load a text file with these commands;

    su
    mount -o remount,rw -t yaffs2 /dev/block/mtdblk8 /data
    cd /data
    rm alog_events
    rm alog.?
    rm plog.log.?
    rm pmlog.log.?
    rm alog_radio.?
    rm alog_system.?
    exit

    .......
    Note:
    I was able to run the a script with SManager and it worked (I'd still like to know how to do it from the terminal).

    This is a YouTube link to the video; http://youtu.be/jmAGTiRdYl8
    1) Open Script Manager
    2) List Script
    3) Edit Mode (so you can see the commands)
    4) Execute (Run) the file
    The 'ls' at the end of the script shows a directory listing with only the base log file names left and of course 'event_logs' is gone.

    #!/system/bin/sh
    cd /data
    ls -l alog*
    ls -l p*.log
    rm alog_events
    rm alog.?
    rm plog.log.?
    rm pmlog.log.?
    rm alog_radio.?
    rm alog_system.?
    ls alog*
    ls p*.log
    exit
     

    Advertisement

  2. mhlsilverdale

    mhlsilverdale Well-Known Member
    Thread Starter
    23

    May 14, 2012
    96
    25
    23
    Pacific Northwest
    Figured it out...

    1) open terminal emulator
    2) SU <enter>
    3) exec sh /mtn/sdcard/scripts/test.sh <enter>

    Trick was to execute a shell in front of the path as seen in (3).

    Video: http://youtu.be/nYAjwpb9B1Q

    >Mark
     
  3. b_randon14

    b_randon14 Well-Known Member
    163

    Aug 13, 2011
    910
    628
    163
    Pizza Delivery Driver
    Somerset, KY
    the best way I have found and it makes it the easiest is to make you a shell script with #!/system/bin/sh at the top line, and then your script after that. Then name the script something easy to remember like rmlogs or something(don't have to put .sh or . anything after it). Then copy that script into /system/bin and give it read write and execute permissions (chmod /system/bin/<name of script> 0755) and now where it is in system/bin, that directory is added to the path of the terminal emulator, so you can simply type in rmlogs on the terminal emulator, and it will execute the script, after calling su of course.

    I make scripts all the time and place them in /system/bin for ease of executing!
     
    svim likes this.
  4. markzombie82

    markzombie82 Well-Known Member
    43

    Feb 19, 2012
    350
    28
    43
    Thanks i almost tied to answer this. Mine would have sucked next to yours. Ha good thing i waited.
     
  5. mhlsilverdale

    mhlsilverdale Well-Known Member
    Thread Starter
    23

    May 14, 2012
    96
    25
    23
    Pacific Northwest
    Thank you,
    Updated video showing me running a script named "ll" (list logs) using your instructions:
    http://youtu.be/s_vSwcW90oU
     
  6. toink

    toink Member
    25

    Feb 20, 2011
    9
    0
    25
    sorry for bumping an old topic, following b_randon14's suggestion, i created adbwifi.sh and content
    it doesn't get executed when typing adbwifi in terminal, and also manually executing it using sh command executes the script, but using getprop service.adb.tcp.port value is not 5555.. any suggestions?
     
  7. John Traner

    John Traner New Member
    15

    Jul 1, 2016
    1
    0
    15
    Male
    Whats the key to exit the script writing. On computer its ctrl d
     

Share This Page

Loading...