You'd have to assume that the Displays system preference was scriptable, which it isn't. You might have a hook to the screen orientation through System events, but I don't know. As somewhat of an AppleScript whiz, I would look at your second question for the answer.
Does anyone know how I can control the rotation of the screen from the command line?
If you can find out which .plist controls the screen orientation/resolution (I think it's one of the byhost prefs in ~/Library) you can use the defaults command to read and write the necessary values to the relevant property list. Then, you can wrap it in an AppleScript using "do shell script" and then execute it using the XKeys utility which can launch an AppleScript using an Fkey.
Also, from what I know from messing with the displays property lists, it's going to be a lot more complex than simply:
defaults write com.apple.displays -int 90 or something similar.