Hey there, blue_angel!
Just wanted to let you know that I've moved your thread here to the Rooted Devices Only section of the Android System Mods, Scripts and Hacks area since your questions principally deal with root (su, etc.) scripting.
Re. the
su binary/program--
su is basically a special version of the
sh shell that also gives you access to root-protected areas of your device. You will still have to give/grant the su binary permission from your SuperUser app (could also be SuperSU, of course).
Like Sepero said, there's a ton of stuff out there on the internet--almost too much to do more than give you a few quick starting points here. But Google is your friend and we'll help you out, too

.
~ ~ ~
Here's a quick demo of some of the nuances of using one shell over the other:
Code:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Scary Alien>[B][B]adb [COLOR="Red"]shell [/COLOR]ls -al /cache[/B][/B]
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
[B][COLOR="blue"]opendir failed, Permission denied[/COLOR][/B]
In the above, you see that a non-rooted request to list the files in the /cache directory is denied.
Code:
C:\Users\Scary Alien>[B]adb shell [COLOR="red"]su[/COLOR] -c "ls -al /cache"[/B]
-rw-r--r-- root root 1500495 2013-02-24 18:41 Superuser.apk
-rw------- root root 43 2012-10-29 22:32 android-root-toolkit-test-root-file-314159265.txt
-rw-rw-rw- root root 35 2012-09-26 20:26 bootanimation-dmesg
drwxrwx--- root root 1969-12-31 19:00 lost+found
drwxrwx--- system cache 2013-06-08 09:25 recovery
-r-xr-xr-x root root 221760 2012-10-06 19:29 update-binary
But using the su binary allows you to successfully list the files.
Code:
C:\Users\Scary Alien>[B]adb shell [COLOR="red"]sh[/COLOR] -c "ls -al /init*"[/B]
-rwxr-x--- root root 109412 1969-12-31 19:00 init
-rwxr-x--- root root 2487 1969-12-31 19:00 init.goldfish.rc
-rwxr-x--- root root 18414 1969-12-31 19:00 init.rc
-rwxr-x--- root root 1795 1969-12-31 19:00 init.trace.rc
-rwxr-x--- root root 6567 1969-12-31 19:00 init.tuna.rc
-rwxr-x--- root root 3570 1969-12-31 19:00 init.tuna.usb.rc
-rwxr-x--- root root 3947 1969-12-31 19:00 init.usb.rc
The above shows that the sh shell can list files (this could have also have been done with a "
adb shell ls -al /init*" command, but I wanted to show how this compares with the example below).
Code:
C:\Users\Scary Alien>[B]adb shell [COLOR="red"]su[/COLOR] -c "ls -al /init*"[/B]
-rwxr-x--- root root 109412 1969-12-31 19:00 init
-rwxr-x--- root root 2487 1969-12-31 19:00 init.goldfish.rc
-rwxr-x--- root root 18414 1969-12-31 19:00 init.rc
-rwxr-x--- root root 1795 1969-12-31 19:00 init.trace.rc
-rwxr-x--- root root 6567 1969-12-31 19:00 init.tuna.rc
-rwxr-x--- root root 3570 1969-12-31 19:00 init.tuna.usb.rc
-rwxr-x--- root root 3947 1969-12-31 19:00 init.usb.rc
And you can also do the same with the su binary, although it would probably be best to only use the su binary when you truly do have root-protect activities to do.
~ ~ ~
Here's a couple of apps that will allow you to write and invoke shell scripts from your phone:
Android Terminal Emulator
Gscript Lite
And the original XDA thread for that app:
[APP] Gscript * Easily launch/save shell scripts from within Android UI *
Script Manager
(I haven't used this one, but it looks pretty good).
Cheers and best of luck!
