A shell can be liberating. You can poke and prod to see what is going on in a system. Would it be nice to do the same in a JVM? This is what grash is all about. For example, you can do a "ls" on your JVM and see what objects are there.Pipes
A pipe is a way to connect the output of one expression to the input of another. I have implemented pipelines in the simplest way at the moment.
/ grash$ ls -a | println size()
The expressions in a pipeline currently evaluate one after another, but in order to behave like Unix, concurrent evaluation of the commands in a pipeline would be desired.
The methods are currently called on the result of the previous evaluation, again this should perhaps be a different mechanism, using the current working instance and others.
Read: grash: a unix-like shell for your JVMgrash home page
Another great idea from http://javanicus.com/blog2/
right after biscuit :-)
...and it's always nice to see someone doing something instead of merely talking about it.
But it does seem more than a little flakey in this initial cut. Something to keep an eye on, to play with, or to contribute to for now, but probably not something to rely on too heavily just yet.
Dave "off to find the bug database" M.
...lest anyone take the above as a slur on the developer, he does very clearly version it as "0.0.0.4", which is commendably honest.
It might also be nice if there were running in portable bytecode a POSIX shell interpreter for traditional access to files and processes.
damn, nice idea!
For fans of modern shells with line editing and command history, you can run it through the jline console utility (http://jline.sf.net
) for a nicer experience with the command:
java -cp jline.jar:grash.jar jline.ConsoleRunner com.javanicus.grash.Grash
Thanks to TheServerSide I have had significant interest in grash, for which I'm very grateful. It's great to see that after only two weeks from the initial idea, I have so many positive suggestions and enhancements to think about.
Marc Prud'hommeaux has directed me towards his wonderful wrapper for streams, called jline, that allows grash to provide line editing and command history.
I have released a new version (grash 0.0.0.5) which now includes this facility by default, both from the command line (java -jar grash.jar) and when embedded. If you have any security issues with this amendment when embedding grash, I have provided a new constructor that allows you to turn this facility off. Marc has very kindly relicensed jline as BSD, so grash is still fully available under an Apache2.0/BSD style license.
On Unix and MacOSX you can simply use the arrow keys to navigate round your most recent commands (on Windows you will have to use CTRL-N/CTRL-P due to an issue in jline). The commands you type are persisted (beyond the session) currently in your home directory in a file cunningly called "~/.grash_history".
I'm quite excited that jline also provides the potential for command line completion (a.k.a. tab completion), this would be a splendid addition which I must look into.
This new release also fixes an issue found by Dave Minter, thanks for the feedback Dave, hopefully you will find things a bit more bulletproof now.
Please keep your thoughts and ideas rolling in, cheers.
jez. (author of grash)
This is such an awseome idea. What would truly be incredible would be to run "top" on my java objects and pipe the output to gnuplot. Here's a wild idea. Implement a way to pipe from this shell into REAL unix programs and vice-versa.
The Unix command line grew around an ecosystems of simple programs that use pipes and redirection. Why not create a similar ecosystem of simple programs for grash with the intent that these programs can interact via pipes and redirection with existing unix programs like grep. I mean, we shouldn't have to rewrite grep.
grash is console/terminal application.
I want to run shell in server JVM (Tomcat for instance) and access it through telnet client.
grash is console/terminal application. I want to run shell in server JVM (Tomcat for instance) and access it through telnet client.Nebojsa
Good idea (security constraints allowing).
FWIW Dave Blevins did a similar thing with OpenEjb, adding a Groovy based telnet client allowing you to query JNDI and EJBs using an interactive Groovy shell. Very handy for querying development / testing servers or scripting MBeans etc.
Enteprise Open Source
FWIW Dave Blevins did a similar thing with OpenEjb, adding a Groovy based telnet client allowing you to query JNDI and EJBs using an interactive Groovy shell.
It'd be nice if this were generalized to apply to J2SE, so that Jini and JXTA could benefit. Since JMX doesn't require J2EE, it'd be better if JMX had a Groovy shell.
e.g. with J2RE 1.5.0-b64 on Windows XP SP1
java -jar grash.jar
Exception in thread "main" java.lang.SecurityException: class "groovy.lang.GroovyShell"'s signer information does not match sign
er information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)