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?
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));
BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With