Telnet calls in wM

Hi All,

Could you please help.

What are the ways of doing telnet calls in webMethods??

I need to telnet a system, do some series of telnet commands to that system to fetch the outputs.

Thanks,
Ganesh

Hi,

You can try calling system commands from a java service to call OS exec.

Here is the sample JS:

inputs:command
synchronous (set to true)

IDataCursor idcPipeline = pipeline.getCursor();
String strOutput = “”;
String strError = “”;
String strCommand = null;
if (idcPipeline.first(“command”))
{
strCommand = (String)idcPipeline.getValue();
}
else
{
throw new ServiceException(“Input field ‘command’ is null”);

		}
			
		idcPipeline.first("synchronous");
		String strSynchronous = (String)idcPipeline.getValue();
	
		Process process = null;
	
		try
		{
			process = (Runtime.getRuntime()).exec(strCommand);
	
			if (strSynchronous.equals("true"))
			{
	
			// Provide an outlet for IO for the process
			String line; 
			BufferedReader ir = new BufferedReader(new InputStreamReader(process.getInputStream())); 
			BufferedReader er = new BufferedReader(new InputStreamReader(process.getErrorStream())); 
			while ((line = ir.readLine()) != null) 
			{
				System.out.println(line);
				strOutput += line + '\n';
			} 
	
			while ((line = er.readLine()) != null) 
			{
				System.out.println(line);
				strError += line + '\n';
			} 
			ir.close(); 
			er.close(); 
	
			process.waitFor();
	
			}
	
		}
		catch (Exception e)
		{
			throw new ServiceException(e);
		}

		finally
		{
			if (strSynchronous.equals("true") && process != null)
			{
				int status = process.exitValue();
				idcPipeline.insertAfter("status", Integer.toString(status));
			}
			idcPipeline.insertAfter("output", strOutput);
			idcPipeline.insertAfter("error", strError);
			process.destroy();
			idcPipeline.destroy();
		}

HTH,
RMG