How do I check the server status using command prompt? I have installed opennms and it is working as expected in GUI mode. But I want to use it in a shell script and hence need a command to check a port on xyz server.
Your question is very unclear. Do you mean you want, from the command-line, to see the results of an OpenNMS poll? Or do you mean you want OpenNMS to perform a custom check using a script?
If the former, you can set up notifications to receive server status through email or pager, or use a text-mode browser to view a node's status. If the latter, the GpMonitor can do what you want.
Alternatively, if the test you want to do can be done in a language that BSF supports, you can use the BSFMonitor instead of the GpMonitor; it should be more performant by way of avoiding having to fork & exec.