Reputation: 143
I've been trying to figure out how to make a sort of command line within Java that acts similar to ComputerCraft's CraftOS interface using known libraries like jBASH and luaj, except it seems that anything I come across either isn't maintained anymore or doesn't function all too well. Unfortunately, dan200 keeps his source under lock and key, so I can't even see how he did it...
Does this mean I might end up having to create my own BASH-y shell and/or my own LUA-y scripting method, or is there something that's being maintained now that is at least somewhat usable?
Upvotes: 3
Views: 228
Reputation: 7922
Upvotes: 2
Reputation: 183301
[…] known libraries like jBASH and luaj, except it seems that anything I come across either isn't maintained anymore or doesn't function all too well.
Luaj is highly-rated on Sourceforge; it was last updated a year ago; and the lack of updates since then might just mean that it hasn't really needed updates. Lua's a pretty simple language.
Even if you find that luaj isn't 100% perfect for you, I imagine that modifying it would be much easier than "having to create my own BASH-y shell and/or my own LUA-y scripting method". (The latter probably wouldn't give 100% perfect results, either, unless you already have experience implementing scripting languages.)
Upvotes: 1
Reputation: 5689
Just to follow up my comment with some code;
Process p = Runtime.getRuntime().exec("/bin/bash");
InputStream stdout = p.getInputStream();
InputStream stderr = p.getErrorStream();
OutputStream stdin = p.getOutputStream();
And you would probably wrap those in BufferedReader
and BufferedWriter
respectively, so that you can use them as character streams, allowing you to do things like read and write lines of text. Eg;
BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout));
Upvotes: 2