Is it possible for a web server to obtain a TOR browsers real IP using only Javascript on the client and server side scripting on the server (cgi/perl/python or whatever)? If so can I see an example script?
Using only JavaScript and a properly functioning modern browser that sends all traffic over TOR, no, a web server cannot get your private IP. However, it's hard to configure TOR so that all traffic is going over it and it's not that hard to combine other tactics with JavaScript to reveal your public IP.
See, for example, Panopticlick, which shows that your browser fingerprint is probably unique already without any hacking. So if anything (like Flash or a PDF reader or Java) sends traffic outside of Tor it can correlate your Tor address with your public IP address.