Forum Discussion

Pritish_Panda's avatar
Pritish_Panda
Contributor
9 years ago
Solved

How can I capture the output of the ShellScript in Groovy ?

Hi,        I am trying to capture the output of the Shell Script by using below pice of code but it is not working for me .   import java.io.InputStream; import com.jcraft.jsch.ChannelSftp; imp...
  • Pritish_Panda's avatar
    9 years ago
     


    import com.jcraft.jsch.*

    Session session = new JSch().getSession("admin","192.168.2.32", 22)
    session.password = "admin123"

    Properties config = [StrictHostKeyChecking:"no"]
    session.config = config
    session.connect()

    Channel channel = session.openChannel("exec")

    channel.inputStream.withReader { input ->
    channel.command = "bash /home/Soapui_Automation/test.sh"
    channel.connect()
    log.info input.text

    }
    channel.disconnect()
    session.disconnect()

     ..

     

     

    Finally I got the code which solved my all problem . By the way Thanks Rao for all your valuable inputs , which really helped me a lot .

     

     

    Thanks 

    Pritish Panda