开发者

Is there anyway by which we can execute interactive commands over Web?

开发者 https://www.devze.com 2023-03-29 23:58 出处:网络
We have a web-framework with Flex and Java, whose basic functionality is to execute commands at the background(Unix)and parse and send it back to the client(Flex). This works fine for all silent comma

We have a web-framework with Flex and Java, whose basic functionality is to execute commands at the background(Unix) and parse and send it back to the client(Flex). This works fine for all silent commands.

We are using Runtime,process to execute commands at java side on request from flex side. The same we need to do for interactive commands/scripts as well.

Is it possible to execute interactive commands/scripts o开发者_开发百科ver web. I tried with apache commons as well but not able to find solution.

Any help would be greatly appreciated.


The difference between CLI and interactive commands is that you have to read from process' STDIN and write to its STDOUT. I do not know about Flex but you definitely can do it with plain HttpRequest although it is not trivial.

Use HTTP POST to run command. But before running it create HTTP GET request. Both GET and POST should have some kind of corelation ID. You can send it using parameter. The GET request will be handled by servlet doGet() that should terminate only when command that you are running is terminated. The POST request should be handled by doPost() and run command. Use PipedOutputStream to connect between your command's STDOUT and servlet's HTTP output stream, so all bytes printed by your application will be passed via HTTP connection and can be shown on UI.

When user types next sub-command send it with post with the same corelation ID, so you will be able to find "right" process on server side and write the passed bytes into its STDIN.

BTW, do you really need all this? Do you probably have easier solution? Anyway, good luck.

0

精彩评论

暂无评论...
验证码 换一张
取 消