Hey, here is some info I found for you. Since I'm not sure exactly how you want your scrip to look like, I was searching some of my favorites for tips on what you want and found this link. Although is for bash scripting you can make the necessary changes if you are using a different shell.
http://linuxdoc.org/LDP/abs/html/
Hope this helps. Let me know.