Running a cmd command using jython.

kamit2733kamit2733 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 import *
def runMyCommand(input, context):
proc = Runtime.getRuntime().exec("cmd /C "dir c:\"")
inStream = BufferedReader(InputStreamReader(proc.getInputStream()))
outputLine = inStream.readLine()
while outputLine != None:
outputLine = inStream.readLine()

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



  • benken_parasoftbenken_parasoft Posts: 617 ✭✭✭
    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.

Sign In or Register to comment.