I am trying to write a script in beanshell for jmeter through which I can get the IP address of a machine (using ipconfig
command and extract only IP Address from the output)?
The following code is giving only the IP of the request of which needs to be passed to jmeter.
String IP = InetAddress.getByName(prev.getURL().getHost()).getHostAddress();
vars.put("IP", IP);
Can anyone guide me?
you can also use as follows:
log.info("IP " + InetAddress.getLocalHost().getHostAddress());
String IP = InetAddress.getLocalHost().getHostAddress();
vars.put("localIP", IP);
later, you can refer the IP using the following syntax:
${localIP} or vars.get("localIP")