Not able to get file name through groovy script from remote server
I used below code on my soap ui project in groovy script to search a file with content using SFTP.
But i am getting process.exitValue = 2 and IO Exepction Stream Closed.
I am running this code on windows.
Can anyone help what is error in this code
import com.jcraft.jsch.*
//
// Properties
//
def testCase = testRunner.testCase;
def String ftpHost = testCase.getPropertyValue("ftpHost")
def int ftpPort = testCase.getPropertyValue("ftpPort").toInteger()
def String ftpUsername = testCase.getPropertyValue("ftpUsername")
def String ftpPassword = testCase.getPropertyValue("ftpPassword")
def String localFilePath = testCase.getPropertyValue("localFilePath")
def String remoteFileDir = testCase.getPropertyValue("remoteFileDir")
//
Session session = null
Channel channel = null
try {
log.info("Starting sftp upload process")
JSch ssh = new JSch()
session = ssh.getSession(ftpUsername, ftpHost, ftpPort)
session.setConfig("StrictHostKeyChecking", "no"); //auto accept secure host
session.setPassword(ftpPassword)
session.connect()
log.info("Connected to session")
channel = session.openChannel("sftp")
channel.connect()
log.info("Connected to channel")
ChannelSftp sftp = (ChannelSftp) channel;
sftp.cd(remoteFileDir);
command = "find . -type f -exec grep -il 'abcas' {} \\;"
def process = command.execute()
def outputStream = new StringBuffer()
def errorStream = new StringBuffer()
process.waitForProcessOutput(outputStream, System.err);
log.info outputStream .toString();
process.consumeProcessOutput(outputStream, errorStream)
process.waitFor()
log.info process.exitValue()
log.info("return code: ${process.exitValue()}")
log.error("standard error: ${process.err.text}")
log.info("standard out: ${process.in.text}" + outStream.toString())
context.testCase.setPropertyValue("propertyName", outStream.toString())