Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Running a cmd command using jython.

kamit2733
kamit2733 Posts: 16

Hi all,

i tried running a cmd command in Soa test but there was no out put

from com.parasoft.api import *
from java.lang import *
from java.io import *
def runMyCommand(input, context):
proc = Runtime.getRuntime().exec("cmd /C "dir c:\"")
inStream = BufferedReader(InputStreamReader(proc.getInputStream()))
outputLine = inStream.readLine()
while outputLine != None:
Application.showMessage(outputLine)
outputLine = inStream.readLine()
inStream.close()

Can some one tell if there is something i have missed in the above code.

Thanks

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited November 2017

    You most likely have a bug in your script. For example, perhaps you really intended to read from the output stream or error stream and not the input stream.

    However, I highly recommend not doing what you are doing in the first place. Instead, please use the External Tool which will do the same thing but do it correctly, no scripting required.