To answer my own question...
One crude way of determining "console is in ssh" is to look at the stacktrace 
from within a command's exec() method:

    private boolean isSshSession(){
        for (StackTraceElement ste : new Exception().getStackTrace()){
            if (ste.getClassName().contains(".ssh.")) return true;
        }
        return false;
    }

-Max


On 2/8/19 3:36 PM, Max Spring wrote:
In a Karaf console command is it possible to determine whether the console 
session is
(a) in Karaf in the foreground (where a Ctrl-D shuts down Karaf), or
(b) an ssh session attached to a Karaf process (where a Ctrl-D merely exits the 
ssh session)?

Context: I'm having my own quit command. It should only do "shutdown" when 
running in mode (a).

Thanks!
-Max

Reply via email to