Thanks for both of the suggestions, but my initial impression is I'd
have to hold off on investigating those now.  Currently, I don't have
any investment in Karaf-specific stuff other than the commands, which
are a normal extension point.

That said, my last question...  Is there any way to automatically run
a command when a bundle loads?

On Tue, May 17, 2011 at 8:29 AM, Guillaume Nodet <[email protected]> wrote:
> As I explained the prompt only deals with commands.  If you print
> anything on the console and if you want the prompt to be displayed
> again. I think the only way would be to create a shell session, and
> then print the prompt that can be retrieved by calling
> Console#getPrompt(), see
> http://svn.apache.org/viewvc/karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/jline/Console.java?revision=1096717&view=markup
>
> I don't really see any other way for now.
>
> Maybe another way would be for you to hack the etc/shell.init.script
> and perform you diagnostics there ? The script is executed between the
> welcome lines and the first prompt...
>
>
> On Tue, May 17, 2011 at 15:13, Samuel Cox <[email protected]> wrote:
>> Shameless bump to give this one more chance;)  I've been reading the
>> documentation on custom commands, but nothing is jumping out...
>>
>> Just to be clear on what I need.  I need to automatically run
>> diagnostics after all my OSGi bundles have loaded.  The results need
>> to be displayed to the user in Karaf's console.
>>
>> The running of the diagnostics is currently be triggered by Spring
>> bean loading (using an init-method).  In the past, it was in a bundle
>> activator.  In neither case, does the karaf prompt show up unless the
>> user hits the Enter key.
>>
>> It's not the end of the world if I can't get this to work, but it would be 
>> nice.
>>
>> On Sat, May 14, 2011 at 8:10 AM, Samuel Cox <[email protected]> wrote:
>>> I'm not executing a command.  We do have our own commands, and they
>>> work fine.  This is just a bean in some bundle that displays some
>>> diagnostics on startup.  If there is a way to execute a command
>>> automatically when a bundle starts, I could print the diagnostics
>>> using that.  I couldn't find any info on doing that.
>>>
>>> Thanks for the help btw!
>>>
>>> On Sat, May 14, 2011 at 7:36 AM, Guillaume Nodet <[email protected]> wrote:
>>>> The prompt is displayed when the execution of a command is finished.
>>>> If you're still executing the command, the prompt won't be dipslayed,
>>>> but you can retrieve it from the shell's session variables and display
>>>> it your self if you need.
>>>>
>>>> On Sat, May 14, 2011 at 14:32, Samuel Cox <[email protected]> wrote:
>>>>> I tried that and it didn't work.  I will say that my bean doing the
>>>>> output is written in Scala.  I'm using println(""), which I think is
>>>>> equivalent to Java's System.out.println("").
>>>>>
>>>>> On Sat, May 14, 2011 at 12:38 AM, Jean-Baptiste Onofré 
>>>>> <[email protected]> wrote:
>>>>>> Hi Samuel,
>>>>>>
>>>>>> It should be the case.
>>>>>>
>>>>>> Karaf shell intercept the std and err output stream.
>>>>>> It means that after a System.out.println(), the Karaf prompt should be
>>>>>> display.
>>>>>> It's the case in the commands. For instance, osgi:list iterates on the
>>>>>> bundles and simply display the bundles attribute using 
>>>>>> System.out.println().
>>>>>>
>>>>>> Try to add a System.out.println("") at the end of your bundle output, it
>>>>>> should display the prompt just after your bundle output.
>>>>>>
>>>>>> Regards
>>>>>> JB
>>>>>>
>>>>>> On 05/14/2011 03:10 AM, Samuel Cox wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Is it possible to get the prompt back after some bundle code does a
>>>>>>> System.out.println()?
>>>>>>>
>>>>>>> I have some beans that need to print stuff to the Karaf console.  I
>>>>>>> can't figure out how to get the prompt back without the user hitting
>>>>>>> enter.
>>>>>>>
>>>>>>> Many thanks.
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Cheers,
>>>> Guillaume Nodet
>>>> ------------------------
>>>> Blog: http://gnodet.blogspot.com/
>>>> ------------------------
>>>> Open Source SOA
>>>> http://fusesource.com
>>>>
>>>> Connect at CamelOne May 24-26
>>>> The Open Source Integration Conference
>>>> http://camelone.com/
>>>>
>>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
> Connect at CamelOne May 24-26
> The Open Source Integration Conference
> http://camelone.com/
>

Reply via email to