yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] danger355:
Words with Frends/AdFree fix

hi,

i just found GScript. there's a fix (androidforums.com/evo-4g-all-things-root/283819-adfree-words-friends.html) for using Adfree while trying to play Words with Friends that unblocks ads for WwF only. it works when i do it manually, but i tried putting it in GScript didn't work. it just left me with a 'stderr:' on the screen (two of them if i removed the first line). my phone is rooted.

everytime you update the local host file in AdFree though you have to do this for WwF to be usable, so this would be great to have.

thanks for any help you guys can give

su root
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
vi /system/etc/hosts
?androidsdk.ads
dd
?mydas.mobi
dd
:wq
[G1 Android Development] fubaya:
It may be the "su root". Just check the box next to "needs su?" and it will run as root without you having to put it in.

If it still doesn't work, try this command.

mount -o rw,remount /system
sed -i -e '/mydas.mobi/d' -e '/androidsdk.ads/d' /system/etc/hosts
[G1 Android Development] danger355:
i kind of thought the same thing, so i tried it every different way: with and without the 'needs su?' checked, and with and without the 'su root' in the code. it never worked with GScript.

same thing with your code... works when i do it manually (both with adb shell and terminal emulator), but not when i try and let GScript do the lifting. though with your code i do see GS doing at least a little bit... some code scrolls up, but it's too fast for me to read. same 'stderr:' error. i'll be using yours from now on though. less typing :)

when i do it manually, i always get some kind of reply, mostly just repeating the commands i typed in (a confirmation?). could this have something to do with why it always errors out with 'stderr:' in GS?
[G1 Android Development] fubaya:
I doubt it. I've been getting the stderr error for months (GScript hasn't been updated in forever) and it must have something to do with newlines. If you run this script:

echo hello

echo world

the output is:

stderr:

echo hello

stderr:

echo world

stderr:

I don't know any other GScript fix for you. If you use Tasker, you can run the command with the Locale Execute Plugin or if you put all this in a file:

#! system/bin/sh
mount -o rw,remount /system
sed -i -e '/mydas.mobi/d' -e '/androidsdk.ads/d' /system/etc/hosts

put the file in /system/bin, then open a terminal and type "chmod 755 /system/bin/scriptname" then you can open a terminal and type the name of the script to run it. Not much help, but it's a little faster than typing it manually.
[G1 Android Development] itm:
Syntax error with MV?

For some reason I'm getting a syntax error with the MV command in the following line:

for file in *.apk ; do mv $f ${f%.bak} ; done

(it is meant to change the extension of all .apk files to .bak)

Can anyone explain what the problem is?
[G1 Android Development] fubaya:
try:

for file in *.apk ; do mv "$file" ${file}.bak ; done

Whatever comes after "for" becomes the variable, in this case "file" so you need to use $file.

(am I the only one who subscribes to this thread?)
[G1 Android Development] itm:
Thanks for your help. Another question - if I want to change the working directory to a directory called "apps" on the sd card, what's the syntax?

I've tried:

cwd='/sd-card/apps'

but it didn't seem to work. The .sh script is being run from the gscript folder on the sd-card.
[G1 Android Development] fubaya:
"cd" is the command to change directories and the sdcard is usually just /sdcard or /mnt/sdcard, so:

cd /sdcard
[G1 Android Development] :
can you run while, for , until infinite loop scripts with this and let it run infinitely in the background?
[G1 Android Development] DocMAX:
anyone knows a script for rescanning sd card?
[G1 Android Development] c3k:
Widgetsoid can create a shortcut to force media scan if this can help you
[G1 Android Development] fabricioemmerick:
Probleming with Moving Apps to SD Card on GB 2.3.3.

In Coby Kyros MID7015

it's because the sdcard is supposed to be mounted as mnt\sdcard... not as mnt\sdcard\tflash... thats the whole deal... and the only way to do this, is changing the init.d files and rebuild boot.img... ;p

Anyone who understands programming could make a script to solve this problem? I would be very grateful. The function only works when moving applications will explore the root and the root change the permission for R / W. thanks
[G1 Android Development] RichieDaze:
To edit init.rc you need to open boot.img. boot.img is mounted on / as read only at boot. It can be edited from / but when you reboot, your changes will disappear.

So why not try a link?

su
busybox ln -s /mnt/sdcard/tflash /mnt/sdcard

Now all the files in tflash should be in sdcard...
[G1 Android Development] fabricioemmerick:
Thanks for responding friend, I'll try and then post the result here. Thanks anyway.
[G1 Android Development] fabricioemmerick:
i tried this, doesnt do anything, i would have mounted tflash but tflash already exists so there is no effect
[G1 Android Development] drawde40599:
is this possible?

With this app is it possible to make a script that would, set brightness to 0, turn off sync background, media, with 1 click?? If so any1 have the Time to write it?
[G1 Android Development] soloxp:
I know this an old post...But you can now do, if not all these shell scripts automatic with tasker and a lot more.

---------- Post added at 07:28 PM ---------- Previous post was at 07:25 PM ----------

Why not just use tasker.
[G1 Android Development] brack11:
I'm on cm7 and I need to change mounting point of external sd card to external_sd, for this i need to edit build.prop and fstab, i usually do it manually but would like to create script that would backup those files, search specific lines in there and replace them with new content (only original lines) can someone consult me on how to do it?
[G1 Android Development] y2d2:
Toggling some really pesky, persistent apps (namely Glu Mobile games and Google Maps) that just won't keep from auto-starting. I've read all kinds of BS about how supposedly great Android is at multi-tasking and memory management and how background apps won't affect performance at all, but we know that's a load of crap.

I named this "pm_toggle.sh", and from GScript, I add a script (named "Toggle ____") that calls it via package name, like:

pm_toggle.sh com.glu.android.ck

#!/system/bin/sh
if [ z"`pm list packages -d $1`" == z"package:$1" ]; then
pm enable $1
else
pm disable $1
fi

This saves you from having a long list of "Enable ___" and "Disable ___" scripts.
[G1 Android Development] y2d2:
So with Ice Cream Sandwich, Android finally admits that having a bunch of apps running in the background is detrimental to performance and battery life, and how it's now so easy to kill apps with just a swipe. Previous stance was that extra apps not killed and running in the background wasn't going to affect a thing because Android is so effective at multitasking, how there was no reason to kill any apps, etc... so efficient, that it would re-launch apps that are used "often", even after killing.

What a joke.
[G1 Android Development] hu_ciao:
Spoof MAC address: preset, random, restore

A couple of shell scripts for MAC address spoofing are posted :cool:

Does random MAC address, spoof preset addresses, reset to original MAC.

Uses valid OUI when randomizing.

Scripts: http://xdaforums.com/showpost.php?p=51072203

Update: http://xdaforums.com/showpost.php?p=51193724

Use tip: http://xdaforums.com/showpost.php?p=51678699

These should work for android systems in general. They are not Samsung specific.

To spoof your own preset addresses add them to MAC.bak, which is generated by script.

From CLI use vi. For the vi averse use echo:

echo (address) >> MAC.bak

Or maybe use root explorer: mount r/w button, long press, open in text editor?

The file will be owned by root.

Enjoy!
[G1 Android Development] idoit:
Hi all,

I want to run a shell script with GScript but I need to pass two arguments to the shell script. Now I decided to read them from user input (stdin). When I use GScript to run this script, it doesn't work but when running from Terminal Emualtor it's fine. Can you help?

read num1 num2
mv folder.$num1 folder.$num2
[G1 Android Development] DiamondJohn:
I am running Dirty Unicons ROM on my Nexus 5 and with that is the ability to assign shortcuts to the NavBar; ie SmartBar. The annoying thing with using GScript Lite was that it would kill itself 13-18 seconds after the script ended, and pop up an alert asking if i wanted to report a failure. the following kills GScript at the end of the script with no appologies. I just added it after the actual script(s).

vNAME="nl.rogro.GScriptLite";
bb=busybox;
vlPID=$($bb ps -T | $bb grep "$vNAME" | $bb awk '{print $1}');
for vPID in "$vlPID"
do
kill -9 $vPID;
done

NB: It assumes you have no other GScripts running at the same time.

---------- Post added at 07:39 PM ---------- Previous post was at 07:34 PM ----------

A very hand reference is the Key Event. For example, I use it to start music.

https://developer.android.com/reference/android/view/KeyEvent.html

Eg to start music, KEYCODE_MEDIA_PLAY

input keyevent 126;
[G1 Android Development] tubaking182:
i currently only need one script, i just added it to my aresenal and has already saved me a huge hassle. it is quite simple, it simply answers and immediately hangs up on a caller. the script is:

radiooptions 9

radiooptions 10

whenever i get a blocked call(which i have gotten 10 of in the last 20 minutes) i just click the shortcut on my homescreen and the phone get's rid of the call and makes sure they cannot leave a voicemail. i hope to make this a little more useful and hopefully have it automate the blocking of these numbers since no one has written a callfirewall app yet for android. :( oh well. this will have to do for now
[G1 Android Development] rogro82:
The gscript_tmp.sh on the sdcard was there for debugging purposes, but since all seems ok im going to change it to a local path so that it doesnt depend on the sdcard.

If there are more wishes for changes etc please post them in the original thread so i can take a look at it.
[G1 Android Development] Proxin:
Awesome, I look forward to it :D

tubaking182, how do you get that to work? I tried putting the shortcut to the script on the Home screen but whenever I get a call, it doesn't let me -go- to my Home screen to be able to click the shortcut.
[G1 Android Development] tubaking182:
when you are receiving a call, hit the back button next to the trackball and you will go to your homescreen, then just hit the shortuc. i am working on getting something that will "listen" to the call screen and when an "Unknown" caller tries calling the phone gets rid of the call before i even know it is coming in
[G1 Android Development] Proxin:
Ah, very nice... but you know, with a free service called TrapCall, you can unblock those blocked numbers.

So far it doesn't work with Verizon but works with AT&T and T-Mobile.

http://www.trapcall.com/

That might be one way to solve your problem. But I do enjoy the script nonetheless. :)
[G1 Android Development] tubaking182:
yeah, i just found out about trapcall and had already setup this script and was using it till i managed to get trapcall setup, now that i have that setup i have plans once they call again
[G1 Android Development] tubaking182:
i don't know how many people use the app, but Fake a call is a great app, and today i wrote a little script to allow you to set a call up on a timer. just follow my template(everything is commented for you so you know what does what)

##change the 30 to your liking, it sets the approximate timer, this entire command can actually go anywhere
sleep 30
##start Fake-a-call Free
am start -a android.action.intent.MAIN -n net.excelltech.fakeacallfree2/net.excelltech.fakeacallfree2.FakeACallSettings
#delete current input in Name line
input keyevent 57
sleep 1 #no sleep was causing typing errors
input keyevent 67
#input callers name here(will appear as if they are calling)
input text (name)
#next line inputs a space between first and last name(or comment out next two lines to only input first name)
input keyevent 62
#input last name
input text (last name)
#move to number line to input the number that will "call" you
input keyevent 20
#clear previous input
input keyevent 57
sleep 1 #no sleep was causing typing errors
input keyevent 67
sleep 1 #had to add another to avoid the modifier key instead of the first number
#input caller's number including the hyphen between goupings, or as a solid number(do not use spaces or it will appear wrong)
input text (insert phone number here ###-###-####) #don't use parenthesis
#go down to the "Ringtone/Call Now" button
input keyevent 20
#next line is for users that have latest version(allows user to choose ringtone)
#input keyevent 21
#press trackball to initiate call
input keyevent 23

keep in mind this will only work if you have installed fake a call on your phone, look for it in the market. if you want to change the amount of time to wait for the call to start you can edit the "sleep 30" in the first line of code to your liking, otherwise you only need to change the number that is "calling" you and the first and last name. this worked great on my phone, any questions i would be more than happy to answer them.
[G1 Android Development] Proxin:
Looks great, tried it on my phone (I'm really trying to be prepared for those "awkward moment" people, they sneak up on you!) but it gives me an error:

Starting: Intent { action=android.action.intent.MAIN comp={net.excelltech.fakeacallfree/net.excelltech.fakeacallfree.FakeACallSettings} }
Error type 3
Error: Activity class {net.excelltech.fakeacallfree/net.excelltech.fakeacallfree.FakeACallSettings} does not exist.
./sdcard/gscript_tmp.sh: 10: Syntax error: "(" unexpected

I have JF RC33 1.42 with apps and cache on SD card.

What do you think would fix this?

*Edit: I looked at my apps and it appears the newest version of Fake A Call Free is called net.excelltech.fakeacallfree2

So I changed it to that and it did indeed open Fake A Call free, but didn't do exactly what the script was supposed to do... it opened up FakeACall Free but only deleted a few of the letters in the first 'input'.

Then when I went back to GScript I noticed a different set of errors:

Starting: Intent { action=android.action.intent.MAIN comp={net.excelltech.fakeacallfree2/net/excelltech/fakeacallfree2.FakeACallSettings} }
Warning: Activity not started, its current task has been brought to the front
./sdcard/gscript_tmp.sh: 10: Syntax error: "(" unexpected

Err... >_<

I feel like a pain, but is there any way to fix this?
[G1 Android Development] tubaking182:
well then apparently i do not have the latest fake a call on my phone, i should be able to fix this in just a few minutes, i'm going to get the latest right now

from the looks of it the only error you are getting in the second code is the "(" unexpected which i believe means that you left the line as

input text (insert phone number here ###-###-####)

rather than changing it to

input text 555-555-5555

make sure there are no parenthesis in the input lines. if you want john do to call then those lines should look like this

...

input text John

input keyevent 62

input text doe

...

input text 555-555-5555

let me know if that helps you out
[G1 Android Development] Proxin:
Got it working :DDD

Good script, I like it. :]

Is there any way it can also select the option to turn Vibrate 'on' before it performs the fake call...?
[G1 Android Development] tubaking182:
just make sure you are not using parenthesis, i edited the above template, you will need to add one more line to it towards the bottom, after inpnut keyevent 20 you need to add a line input keyevent 21 to move the focus over to the call button, or you can even have it select a ringtone for the person if you have custom ringtones for certain people

to do that you will need to count how many ringtowns from the top the one you want to use is and place this code in after line 25

input tkeyevent 20

(repeat as many times as needed to get to the correct ringtone)

input keyevent 23

(continue script here)

hopefully he doesn't release it as a "new" app each time and i can keep my scripts updated.
[G1 Android Development] tubaking182:
you will have to manually run the program one time and just enable it manually, if i were to write it into the script then it would only be enable every other time, and i didn't want to do that. the app saves your header settings(name and number) as well as vibrate, i am not sure about the ringtone setting, i will start playing with that too
[G1 Android Development] Proxin:
It seems that after the time I tried it and it worked, all times after that, it's clicked on Set Ringtone instead of clicking the Call button...

Are there any sources I could look to, to find more information on how to cycle through directional options? I picked up that keyevent 20 is move down, I can flounder around and figure it out eventually what the rest do but it would be nice to have a command table of some sort

*Edit: It's working like a charm now, pardon my noobishness. :)

Thanks again!

Ooh, the problem was that I had the phone open one time, as opposed to closed.

The layout changes, and somehow the Ringtone changer and Call buttons get switched.
[G1 Android Development] Proxin:
What is the command to clear everything on a script's terminal...?

If that script is run twice, it will have excess script left from the previous time it has been run.

Perhaps somehow it could be set to change the background service nl.rogro.GScript to add the 'clear' command upon exiting the phone?

Hmm... I was considering the idea of

Just throwing ideas out... it's late, my imagination is everywhere on this.

I've now tried putting

input keyevent 4

before and after the entire script. That seems to help stop the problem of troubles repeating the procedure... but I'm still encountering some glitches so I'm not setting it down yet.

I also want to figure out a way to have it so you can start the script, press the red "screen-off" button (so nobody notices your phone is acting on its own will), and have the script run in the background.

However, this is very troublesome, as the keyguard goes on when it shuts off the screen. Which means any background app that tries to use input keyevents will run into the same problem as you would if you tried any keys with the keyguard turned on.
[G1 Android Development] tubaking182:
here is a txt file letting you know all the keys and their corresponding number for keyevent. hope this will help, i did throw in an extra line of code but i commented it out for those that have to old version since the app doesn't have an update . 20 is down and 21 is left but everything is in here. i am currently working on a script that will bring up the last one to call you so there is less time the phone is acting on it's own. i have tried pressing the red call button to put it to sleep but it won't continue to run.

i will see what else i can do for this script since i am not good enough to program an app that will run in the background.
[G1 Android Development] Proxin:
That is indeed very helpful, thanks!

I edited the script a bit to work with my settings, I'm trying something new of having the script press Home once before it starts, because I've found if you don't do this, the leftover script still is left in the GScript and doesn't clear out until you press Close at the bottom. Which causes problems for the script running a second time.

Maybe there are better workarounds to this... but it's late, I'll take a look at it more tomorrow.
[G1 Android Development] rogro82:
Just post the bug/wish in my development thread ( in applications ) and ill take a look at it :)
[G1 Android Development] T-McGill:
Playing around with themes and the Magic build , I end up doing a wipe often. After each wipe, I have to enter the wpa key for my home wifi router. I was looking for a script to turn on wifi, enter the wpa key and log onto the network. Thanks to tubaking182's help the following script works great. Thank you tubaking182! :D

am start -a android.intent.action.MAIN -n com.android.settings/com.android.settings.Settings

sleep 1

input keyevent 20

input keyevent 23

sleep 1

#open wireless controls

input keyevent 23 #you can comment out this line if your wifi is already on

#open wifi settings

input keyevent 20

input keyevent 23

#scroll to network

input keyevent 20

input keyevent 20 #this should land the focus on the first wireless network which should be the network with the strongest signal which i would hope is yours

#(repeat as needed)

input keyevent 23

sleep 1

input text "wireless key goes here without quotes"

# Move the focus to the Connect button and push it

input keyevent 20

input keyevent 20

input keyevent 23

#returtn to home screen

input keyevent 3
[G1 Android Development] tubaking182:
am -a start android.intent.action.MAIN -n com.android.settings/com.android.settings.WifiSettings

#scroll to network

input keyevent 20

input keyevent 20

input keyevent 20 #this should land the focus on the first wireless network which should be the network with the strongest signal which i would hope is yours

#(repeat as needed)

input keyevent 23

sleep 1

input text "wireless key goes here without quotes"

# Move the focus to the Connect button and push it

input keyevent 20

input keyevent 20

input keyevent 23

#returtn to home screen

input keyevent 3

i actually cleaned it up a bit right after i posted it, and then it went missing do to the rougue account on XDA, but this should work just as good with a whole lot less code and therefore run faster
[G1 Android Development] G1student:
How would these be different if you have apps and data on sdcard
[G1 Android Development] bmfc187:
Instead of

rm -r /data/data/com.android.browser/cache/webviewCache

you would put:

rm -r /sdcard/cache/com.android.browser/cache/webviewCache

and the same for the rest, substituting the /data/data dir. for the dir. on your sdcard where your caches are...mine is /sdcard/cache/.
[G1 Android Development] LucidREM:
Instead of

rm -r /data/data/com.android.browser/cache/webviewCache

you would put:

rm -r /system/sd/data/com.android.browser/cache/webviewCache

you have to make sure you answer the right questions
[G1 Android Development] a1t:
OC

I was trying to create shortcuts on the home screen to all for 'one-click OC and/or restore'

(p.s. I didn't discover this)

• This will tell the phone to run at 528 MHz until it is rebooted:

su

echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq

• This will verify the settings:

su

cat /proc/cpuinfo

• Note: You can set a minimum speed for battery conservation of:

echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

echo 128000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
[G1 Android Development] haitiankid4lyf:
this will back up the assets database, which controls what appears in the my downloads part of the market, perfect if u have apps on ur sdcard and dont want to reinstall them all

this backs up

su
mkdir /sdcard/market
busybox cp /data/data/com.android.vending/databases/assets.db /sdcard/market/assets.db

this restores

su
busybox rm /data/data/com.android.vending/databases/assets.db
busybox cp /sdcard/market/assets.db /data/data/com.android.vending/databases/assets.db
[G1 Android Development] :
How do you use gscripts of your sd card?
[G1 Android Development] savethechicken:
You Create a new Script then on the rigth side you will see load file. Select that then select the .sh file off the SDCard.
[G1 Android Development] :
Your the bestest.
[G1 Android Development] :
I have apps on sd card but not data, but neither of these work for me.
[G1 Android Development] :
And also is there a way to make a script that will restore a nandroid backup.
[G1 Android Development] robpet2:
This is great info... will prob use the overclock, and the reboot script..
[G1 Android Development] beagz:
for you maps cache clearers the new directory is /data/data/com.google.android.apps.maps/cache/webviewCache

if using 1.5