Android OS2.2 used to have an option under Settings/Applications/Development to disable screen lock during USB debugging. After upgrading my Samsung Galaxy S to OS2.3.3 this
# find out if screen is on works on android 5.0+
screenOn=`adb shell dumpsys power | grep "Display Power" | grep ON`
if [ -z "$screenOn" ]; then
echo "turning screen on"
adb shell input keyevent KEYCODE_POWER
# unlock by emulating slide up
adb shell input touchscreen swipe 930 880 930 380
fi