Here's how you can do it.
– Manas .
Volume:
Hey Randall, here's how you
change the volume .
Copy the code to a new file, name it "say.php" (or whatever else you want to call it) and put it in Macintosh HD /Library/WebServer/Documents/. Remember, this is the top-level /Library directory, not the one under your own user account. You also need to make sure that Web Sharing has been turned on under System Preferences > Sharing.
Open a browser, and type in:
http://localhost/say.php
from your own machine.
To do this from another machine connected to the same router, use the Bonjour name of your Mac (this can be found under System Preferences > Sharing.) E.g.
https://Manas-Desktop.local/say.php
To do this from a machine outside your router, you need to have configured your router correctly. And if you can do that, you don't need me to tell how to do the rest of it.
Bonus feature: this script also lets you increase and decrease the volume. Perhaps then, Randall's roommate might have heard him.
To achieve what this script does, it needs to take input from the Web and use it in a command that executes in a shell. The input is sanitized and I believe that such a risk is minimal. However, if you're concerned about this possibility, do not install this script. You are responsible for what you do with this script and your machine. If you're really concerned, put it inside an authenticated session.
Update: Added a command injection filter suggested by Mac OS X Hints user skicker.