Forum Discussion

anshul_nayak's avatar
anshul_nayak
New Contributor
8 years ago

I need to send JSON response from command line in between REST request execution.

My scenario is - 

I have a REST request with POST method, in between of REST request execution I need to send a JSON response from command line. I have groovy script to run rest request - "def executionResponse = (testRunner.runTestStep( project.testSuites[testSuiteName.getContents()].testCases[testCaseName.getContents()].testSteps[testStepName.getContents()] ))". Now I need some code to call command prompt and execute my command. I have that code as well, but not able to call at same time.

 

Command line code - 

String cmd = "Some Command to be execute."

File currentDirFile = new File(".");
log.info("executing emulator command");
String dir = currentDirFile.getAbsolutePath().replace(".",
"Utils\\FusionDeviceEmulatorUtility\\");
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd /c start cmd.exe /K \"cd " + dir + "&& "
+ cmd + "&& exit");
log.info("Executed command Process - "+proc);

 

Please suggest me how i can call both scenario at same time.