I assume you have a password-less SSH key set up so that ssh does not prompt for a password.
You can use a bash script like this:
#!/bin/bash ssh server -L 3392:192.168.1.138:3389 -N & SSH_PID=$! sleep 5 # wait for the connection to establish rdesktop 127.0.0.1:3392 kill $SSH_PID
I'm making an assumption here that rdesktop does not fork and return until the program ends. If it does, the SSH connection will die immediately. If that's true, you'd need to watch for running rdesktop processes, loop/sleep until they're all dead, and then close the SSH connection.