execute commands of another program from a tidesdk program

可紊 提交于 2019-12-08 03:16:56

问题


I'm testing tidesdk.

I have a java program that reads from standard input. I run the program through the console console

java -cp MyProgram.jar package.MyMainClass

And then execute commands and get results.

there any way to do with tidesdk?

Edit: The problem was that calls the java program with a list of one element (which contained the command separated by spaces) It solved with passing every word to a item of list (and removing the spaces). Right now I have porblemas to write standard input. This is what I'm trying.

 var input = Ti.Process.createPipe();

 var process = Ti.Process.createProcess({
                   args:['java', '-cp', 'C:/.../MyProgram.jar', 'package.MyMainClass'],
                   stdin: input
                });

    //process.setOnReadLine(function(line) { alert(line) });
    process.launch();

    input.write("comand parameter1 parameter2\n"); //This line does not work

The java program starts. But never gets a command.


回答1:


Checkout Documentation of Ti.Process.createProcess. That is exactly what you are looking for:

http://tidesdk.multipart.net/docs/user-dev/generated/#!/api/Ti.Process



来源:https://stackoverflow.com/questions/16486779/execute-commands-of-another-program-from-a-tidesdk-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!