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

pre-install phase - execute binary

I must be doing something wrong (again). During the pre-install phase, I input a tcpip port # from the user. Before I go to the next step, I'd like to see if this port is ok to use or not.
I wrote some java code that opens a socket to determine if it's available (or not). My test code works ok.
However, is there a way to call this? I tried using $USER_INSTALL_DIR$\myfile, etc. However, $USER_INSTALL_DIR$ doesn't exist yet.

I currently execute the check in the post-install phase. It works - but would be much nicer to execute in pre-install (imho).
Labels (1)
0 Kudos
(2) Replies
james_decosta
Level 9

hi,
we can do like this :
You use a message dialog feature of installanywhere,
then you add a custom code rule on the message dialog
by clicking on evaluate custom rule
Give the path of the jar file which contains the TCPIPPORT.class
Give the fully qualified name of the class next
like com.xxx.installer.TCPIPPORT(.CLASS extension is not required dont give)

Write a custom code rule like this:

public class TCPPORTRuleAnother extends CustomCodeRule {
public boolean evaluateRule() {

try {
/* Write your code for verification here
if it is a TCPIP port
then */
return false
}
else {
return true}
}
}
0 Kudos
Kondalarao_n
Level 3

public boolean evaluateRule()
{
if (!portValue.equals(System.getProperty("port")))
{
if (portScan("localhost", Integer.parseInt(portValue)))
{
ruleProxy.setVariable("errorMsg", "Port number " + portValue + " Port already in use.");
return true;
}
System.setProperty("port", portValue);
}

if (!shutdownPortValue.equals(System.getProperty("shutdownPort")))
{
if (portScan("localhost", Integer.parseInt(shutdownPortValue)))
{
ruleProxy.setVariable("errorMsg", "ShutdownPort number " + shutdownPortValue + " Port already in use.");
return true;
}
System.setProperty("shutdownPort", shutdownPortValue);
}
0 Kudos