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
Replace 12345 by your unlock code. Then this shell script unlocks your phone:
adb shell input keyevent KEYCODE_WAKEUP # activate
adb shell input touchscreen swipe 530 1420 530 1120 # swipe up
adb shell input text 12345 # input password
adb shell input keyevent 66 # press enter
You should never disable security features on your phone (as pointed out above). Make sure nobody can read that script file either.