Hi,
Is there any way that I can fetch a file path from remote server and the same file path will be used in my SoapUI rest Project
Thanks
Pritish Panda
Solved! Go to Solution.
Here you go:
/** * edit and write your command below */ def command = "you batch script command" log.info command def process = command.execute() def outputStream = new StringBuffer() def errorStream = new StringBuffer() process.consumeProcessOutput(outputStream, errorStream) process.waitFor() 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())
The output of batch script is now set into test case level proprty called "propertyName". And use property expansion i.e., ${#TestCase#propertyName} where it is needed.
Hi Pritish,
Could you please clarify your request? What remote file do you want to get? What do you mean by a remote server?
Hi Tanya,
Actually I have a file in my Linux server / HDFS (Remote location) & I would like to featch the file path from linux server .
So I am able to fetch the file path by using a ShellScript. Same file path I would like to use in my RestStep in SoapUI .
Is there any way that I can pass that value to SoapUI So that can be used in my RestStep ?
Thanks
Pritish Panda
No Rao,
I don't want to download the file, I just want to pass the File path to SoapUI so that I can use that in my Json and Execute the RestStep .
I mean the output of shellscript will be used in soapui .
although ,I wrote the output in text file inside Remote Linux server but i am not able to read the file .
Please give me any solution for this ?
Thanks
Pritish Panda
Hi Rao,
Ya that is what I am looking for , How can we capture the output of the ShellScript in Groovy ?
That Shell Script output will return me the File path and that path will be used in my RestRequest .
Thanks
Pritish Panda
Here you go:
/** * edit and write your command below */ def command = "you batch script command" log.info command def process = command.execute() def outputStream = new StringBuffer() def errorStream = new StringBuffer() process.consumeProcessOutput(outputStream, errorStream) process.waitFor() 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())
The output of batch script is now set into test case level proprty called "propertyName". And use property expansion i.e., ${#TestCase#propertyName} where it is needed.
Hi Rao ,
import java.io.InputStream;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;
import com.jcraft.jsch.*
import java.io.*
import java.lang.*
JSch jsch = new JSch();
Session session = jsch.getSession("admin","192.168.2.32", 22);
session.setPassword("admin123");
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect()
Channel channel = session.openChannel("exec");
channel.connect();
//def command=((ChannelExec)channel).setCommand("bash /home/bedrock/Soapui_Automation/test.sh");
def command = "bash /home/bedrock/Soapui_Automation/test.sh"
def process = command.execute()
def outputStream = new StringBuffer()
def errorStream = new StringBuffer()
process.consumeProcessOutput(outputStream ,errorStream)
process.waitFor()
log.info("return code: ${process.exitValue()}")
log.error("standard error: ${process.err.text}")
log.info("standard out: ${process.in.text}" + outputStream.toString())
channel.disconnect();
session.disconnect();
I am trying with this code but its not working for me .
Responce-:
Thu Jan 28 15:00:18 IST 2016:INFO:return code: 1
Thu Jan 28 15:00:18 IST 2016:ERROR:standard error:
Thu Jan 28 15:00:18 IST 2016:INFO:standard out:
Can you check it out where is the problem in the above code ?
Thanks
Pritish Panda
Subject | Author | Latest Post |
---|---|---|