Katalon connectivity with putty

I am new to Katalon. My project is hosted to a remote machine. I can access to URL but i need to access the remote machine from my desktop and run some linux command on that machine.

Is is possible to access the remote machine and run some command by Katalon.

Thanks in advance.

Regards,
Tarun

why don’t you just use putty?
or if you want to execute a script, check winsshterm, has a nice ‘script mode’ feature
what commands you need to run on the target machine?

Hi,

do it by using java

import io.netty.channel.Channel

import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class ReadSSHFile {

	@Keyword
	public void readSsh(){

		JSch jsch = new JSch();
		Session session = null;
		try {
			session = jsch.getSession("user", "127.0.0.1", 22);
			session.setConfig("StrictHostKeyChecking", "no");
			session.setPassword("password");
			session.connect();

			Channel channel = session.openChannel("sftp");
			channel.connect();
			ChannelSftp sftpChannel = (ChannelSftp) channel;

			InputStream stream = sftpChannel.get("C:/Users/xxx/Desktop/data/myinifile.ini");
			try {
				BufferedReader br = new BufferedReader(new InputStreamReader(stream));
				String line;
				while ((line = br.readLine()) != null) {
					System.out.println(line);
				}
			} catch (IOException io) {
				System.out.println("Exception occurred during reading file from SFTP server due to " + io.getMessage());
				io.getMessage();
			} catch (Exception e) {
				System.out.println("Exception occurred during reading file from SFTP server due to " + e.getMessage());
				e.getMessage();
			}

			sftpChannel.exit();
			session.disconnect();
		} catch (JSchException e) {
			e.printStackTrace();
		} catch (SftpException e) {
			e.printStackTrace();
		}
	}
}

Thanks for the reply.
Anything is ok. i have to just open that and run command by automation.
The command is internal to my project.

i am sorry, not working

hello,

which was not working?

Hi
i am getting "2019-06-10 13:52:23.074 ERROR k.k.c.m.CustomKeywordDelegatingMetaClass - :x: Cannot cast object ‘com.jcraft.jsch.ChannelSftp@9bd0fa6’ with class ‘com.jcraft.jsch.ChannelSftp’ to class ‘io.netty.channel.Channel’

ChannelSftp sftpChannel = (ChannelSftp) channel; - this line causes the problem

hi,

and these all are imported as should be?

import io.netty.channel.Channel

import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

Yes all are added.