Simulate hardware keyboard input
#!/bin/bash
# Get the simulated key
KEY=$1
#print variable on a screen
echo "Send heardware key '$KEY'"
case "$OSTYPE" in
darwin*)
echo "OSX"
# osascript -e 'tell application System Events" to key code 0'
# osascript -e 'tell application "System Events" to keystroke "a"'
osascript -e 'tell application "System Events" to keystroke "'$KEY'"'
;;
linux*)
echo "LINUX"
# Rely on 'xdotool':
# You should install it by 'sudo apt-get install xdotool'
xdotool key $KEY
;;
solaris*) echo "SOLARIS" ;;
bsd*) echo "BSD" ;;
*) echo "unknown: $OSTYPE" ;;
esac