You can't issue commands to a server without being on it.
What you can do though is create a socket script to connect to an IRC server, get the information, and disconnect again, but for that you will need to know some of the IRC protocol (rfc 1459). Hammer wrote something a long time ago on here for messaging people on other networks, I'm sure it could be modified to do what you ask, it should at least give you an idea of how to start.
Here it is.