https://github.com/CrosseyeJack/WiringPi/tree/readmode-patch - This is a small mod to gpio.c to add the command 'readmode'. It will return the mode the given pin is in which is helpful for automated scripts to check the mode a pin instead of just blindlingly setting the mode fo the pin over and over again. I added this feature as I needed the feature myself andi'm releasing the changes as because that is what the pi is all about.
read-n-toggle.sh [txt] [.sh] - Usage: ./rean-n-toggle.sh <pin number> ex: ./read-n-toggle.sh 7
A tiny script that just takes a gpio pin number, reads its state, sets it to an output if needed and toggles the high/low state of the pin. Just written to play around and test the WiringPi libary. It doesn't have any "input protection" but it will give you an idea on how to take an argument from the bash script, use it to read a pin, and use that to process a change. (make sure you chmod 750 the file :-p)