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 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_parasoftbenken_parasoft Posts: 522 ✭✭✭
    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.