Friends of Eclipse,
Eclipse is an open source community that benefits millions of developers around the world each and every day! During the month of September, we are asking you to give back to our wonderful open source community. All donations will be used to improve Eclipse technology. Your contribution counts!
We thank you for this gesture, and for giving back to our community.
osgi.console.sshin the config.ini file. For both properties, you can also specify the host:
osgi.console=<host>:<port>where <host> is either localhost or 127.0.0.1, so that the console listens for telnet connections only from the localhost.
java -Djava.util.logging.config.file=configuration/logging.properties \
osgi.console.enable.builtin=falsedisables the Equinox built-in console. It must be disabled in order for the new console to work properly.
osgi.console.ssh.useDefaultSecureStorageis necessary only if ssh is used and the default login mechanism is used (i. e., a custom login module is not provided)
osgi.console.ssh.useDefaultSecureStoragemust be set to
true. The file, where the users are stored, is specified through the property
Using Custom JAAS Authentication Login ModuleCustom JAAS authentication login modules could be used with the ssh instead of the default one. If a custom login module is used, then the property
osgi.console.ssh.useDefaultSecureStoragemust not be set at all. The custom module must be specified in the file
org.eclipse.equinox.console.authentication.configinstead of the default entry there, or in a different file. If a different file is used, then its name must be specified as the value of the property
org.eclipse.equinox.console.authentication.config. Also, it will be necessary to create a fragment to sshd-core bundle, with which to import the package of the custom login module. This is necessary for the sshd to be able to load the module class.
Configuring of telnet and ssh host and port through Configuration Admin serviceThe console provides the option to configure the telnet and ssh host and port through Configuration Admin instead of through the properties
osgi.console.ssh=<host>:<port>. This could be helpful in more complex scenarios, for example when you want to run different instances of the console in different subsystems of the framework. In this case if the port is configured through a system property, it is one and the same for all console instances and only one will be able to bind to the socket. If this feature is used, then you should:
- set the property
- install and start, along with the console bundles, the org.eclipse.equinox.cm bundle and its dependencies
write a bundle to provide the configuration with the telnet and ssh properties The configuration PID for the telnet configuration is
osgi.console.telnetand for the ssh configuration is
osgi.console.ssh. Both configurations have the following properties:
All must have values of type String. The
enabledproperty determines if telnet/ssh is to be started at all. If the value is
true, telnet/ssh is started. If the value is
false, or the property
enabledis absent, the telnet/ssh is not started.
Using CommandsThe Gogo shell, on which the new console is based, supports different type of commands from these currently supported in Equinox. Currently in Equinox, commands are provided by a class implementing the
CommandProviderinterface. The new console provides an adapter from this type of commands to the new type of commands, used in Gogo and specified in RFC 147. The RFC 147 commands are arbitrary classes, registered as services, with two special properties:
The commands in the new console use the notion of command scope. The scope can be used, for example, to differentiate between commands with one and the same name, but provided by different providers. Then they should have different scopes.
osgi.command.scope- specifies the scope of the command
osgi.command.function- specifies the commands provided by this service; this is a list of the names of public methods in the service class, which must be available for execution as commands
The scope is a prefix of the command name, separated from it with a column. When writing the command in the console, the scope may or may not be specified. If the scope is not specified, then the command with this name from the default scope is used. If in the default scope there is no command with such name, all commands are searched.
If there is more than one command with the specified name in different scopes, it is not guaranteed which one will be actually executed. Therefore, if you know that there are commands with the same name but different scopes, you must explicitly prefix the command name with the scope to ensure that you will get executed exactly the command you want.
The legacy commands, adapted by the new console, have scope
Getting Help for CommandsThe default help command in Gogo lists the names of the registered commands, and if it is called with a command name as an argument, it displays help message for the specified command. The default help command does not provide help for the legacy Equinox commands, which are adapted by the new console. For this reason the new console provides its own help command, which calls the default help, but could also provide help for the legacy commands.
If no argument is specified the names of all new commands are displayed.
If a command name is specified, the help message for this command is displayed. If the command is legacy and the
CommandProvider, which provides this command, does not provide separate help for each command (this is a new feature, introduced in Equinox 3.7), then the help messages for all commands in this
The help command, provided by the new console, should be explicitly scoped, as in
There is also a
mancommand. It accepts the same arguments as the help command and has the same semantics.
Writing RFC 147 CommandsWriting RFC 147 commands is easy. You have to do the following:
Something new for the RFC 147 commands are the converters and formatters.
- Write your class with all commands you want implemented as public methods. Methods may have arbitrary arguments. Also, unlike Equinox command providers, in RFC 147 there is no interface that the class of the command provider should implement.
- Register the command provider as a service with the two properties, described above.
The converter is a class which converts the arguments, passed on the command line, to the actual arguments, which the command accepts. For example, the command may have one argument of type
Bundle. There may be a converter, which from a long finds the bundle with this id. Then the command may be called with the ID of the bundle as an argument, the converter will convert it to the corresponding
Bundleobject and the command method will be called with this object as an argument.
The formatter is a class which displays the result, returned by the command method.
For more information on RFC 147 commands, you can check the Gogo documentation.
Tab CompletionThe console provides tab completion. This feature is available only when connecting through telnet or ssh.
Completion is available for:
- command names
- variable names - these must be previously defined in the session; variable names may be passed as command arguments
- file names - passed as command arguments
tabkey is typed, all possible candidates for completion for the current word are searched. If there is only one possible completion, the current word is automatically completed. If there are more than one options, all are displayed in a column. The possible options can be iterated by hitting
tabmultiple times, until the desired completion candidate is reached.
If longest common prefix of all available completion candidates is longer than the current word, then the current word is completed automatically to this prefix, before choosing the final completion. For example, if we have the following available completions for the word
the current word is completed automatically to
bundle, and then by hitting
tabyou can choose which completion you like, or may type it for yourself.
The console allows custom command completers to be provided. A custom completer should implement the interface
org.eclipse.equinox.console.common.Completer, provided by the bundle of the new console. It has the single method
getCandidates, which get as a parameter the whole command line and the current cursor position in it, and returns a map with all completion candidates, and the position in the command line, on which the completion begins. The keys in the map are the candidates, and the values - the start position for the completion.
Closing Telnet or Ssh SessionBoth telnet and ssh sessions are closed with the disconnect command.
Running Non-interactive ShellIn some cases you may wish to run the console without an interactive session. In this case, the console can be connected from telnet and ssh, but is not available on standard in and out. For this the following property should be specified:
Back to the top