It's theorically doable, but really tricky. The reason is that you have to duplicate line editing in java the same way the native shell will, else you'll end up with a different command line. Let's take an exmple: the user enter <g> <i> <t> <home> <del> <del> <c> <a> You need to make sure, your java buffer actually contains <cat> and not <gitca> for example. It's really not easy, and that's what jline does, but making sure your native shell *and* jline behave exactly the same is ... tricky. If you have a limited and known set of commands, I don't see why you would not go full jline. If you don't and want to add some smart things to your shell, I'd really recommend using shell scripts for that. Mixing both it imho not the right thing to do.
On Thu, Jan 24, 2013 at 12:34 PM, Ioan Eugen Stan <stan.ieu...@gmail.com>wrote: > Hello, > > Darn, I wished it was easier. I managed to get a 'dumb' Karaf Dhell up > and running by passing a org.apache.karaf.shell.ssh.ShellFactoryImpl > to the server [1], [2]. > Like you said, I should delegate all commands except for the ones that > on the 'Fake List' which will be treated separately. > > But I still wonder if I could delegate command completion to the > native shell somehow, maybe in the background. I mean, command > completion is done when the user sends some text followed by two TAB > characters. At that point the shell responds with some text. I guess > I'll use a native interactive shell and run some experiments. > > Wish me luck and ping me if you get some ideas. > > Cheers, > > [1] > https://github.com/apache/karaf/blob/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml > [2] > https://github.com/apache/karaf/blob/trunk/shell/console/src/test/java/org/apache/karaf/shell/console/ExampleSubclassMain.java > > > On Thu, Jan 24, 2013 at 1:11 PM, Guillaume Nodet <gno...@gmail.com> wrote: > > If I understand you correcly, you're trying to launch a native shell, but > > have some kind of pre-processing of commands in java. > > The problem is that there's no way afaik to get back from the native > shell > > to the sshd environement. > > I guess you could customize your native shell to some point to do some of > > the processing in scripts, like creating bash functions that will act as > > proxy to the native commands and do your ignore/execute logic there. > > Else, I'd really suggest using jline as the shell and implement jline > > commands that would then delegate to native commands. > > > > > > > > On Thu, Jan 24, 2013 at 11:37 AM, Ioan Eugen Stan <stan.ieu...@gmail.com > >wrote: > > > >> Hello Guillaume, > >> > >> Thank you for your quick response and the pointers. I know SSHD does > >> not aim at providing an interactive shell, but I'm not planning to > >> re-implement it myself also. Is it possible for example to delegate > >> all characters to the native shell and on new-line to decide one of > >> the two: > >> > >> - if the command entered so far is not to be executed then drop it > >> silently and return fake output to the user > >> - if the command should be executed - forward the newline to the > >> native, interactive shell > >> > >> This should avoid the need for re-implementing the commands and > >> command completers and leverage the native shells command completing > >> capabilities. Is this ok? > >> > >> By the way, you did incredible work on SSHD and jline. > >> > >> Cheers, > >> > >> -- > >> Ioan Eugen Stan / CTO / http://axemblr.com > >> > > > > > > > > -- > > ------------------------ > > Guillaume Nodet > > ------------------------ > > Blog: http://gnodet.blogspot.com/ > > ------------------------ > > FuseSource, Integration everywhere > > http://fusesource.com > > > > -- > Ioan Eugen Stan / CTO / http://axemblr.com > -- ------------------------ Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/ ------------------------ FuseSource, Integration everywhere http://fusesource.com