cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ridch01
Level 5

tomcat port check

My installer will set up tomcat. It asks for your port number prior to updating server.xml (i.e. http://localhost:some_port). My installer needs to do a quick check to see if that port is in use (currently on Windows 2003 Server).
So, I create a "execute command" action that does 'netstat -an|find "$TOMCATPORT$"'. I store STDOUT from this command to another IA variable.
I then have a dialog that will display the port is in use (and a jump to take you back). I basically am saying if $STDOUT$ containst $TOMCATPORT$ - display this box, then jump back to the label.
I don't think the $TOMCATPORT is expanding within the find. I can see that $STDERR$ is set for my command.
Is there a way to pass the quotes to find?
Perhaps there is a better way to check if the port is in use? I wanted to avoid writing code if possible.
Labels (1)
0 Kudos

(2) Replies
Christopher_Pai
Level 16

Google for "TCPView source" for tips on calling the API's that netstat calls for enumerating active listening tcp ports.
0 Kudos
ridch01
Level 5

Thanks. I'm trying to avoid any code specific to the installer at this point. However, I may have to write some tools like this.
For now, I am just calling "netstat -an" (and dropped the find ). I then have a screen to see if STDOUT from the call has the tomcat port the user typed in. Of course, this isn't perfect.
If they type in "123" for the port and netstat -an reports "12345" is in use, my test won't work. Given my time constraints, it's ok at this juncture.
0 Kudos