Here you’ll find some examples of how to run Vert.x Shell and how to extend it with custom commands
Vert.x Shell provides a Shell for Vert.x with out of the box commands, it can be extended easily to add custom commands. Users can connect to the shell via SSH or Telnet.
This example shows how to deploy the Vert.x Shell service available via SSH as a packaged Vert.x service.
The SSH connector is configured to use the keystore.jks as SSH key pair store and the auth.properties for user authentication.
The service is deployed using the service:io.vertx.ext.shell deployment name that starts the Shell Service as a verticle.
Run the shell either in your IDE or on the command line, then connect to the shell using
ssh -p 3000 admin@localhost
(password is password) and type help
to show the available commands
This example can also be started from the command line
This example shows how to deploy the Vert.x Shell service available via Telnet as a packaged Vert.x service.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type help
to show the available commands
This example shows how to deploy the Vert.x Shell service available via Http as a packaged Vert.x service.
Run the shell either in your IDE or on the command line, then point your browser to http://localhost:8080/shell.html
and type help
to show the available commands
This example shows how to run the Vert.x Shell service available via SSH as a packaged Vert.x service.
Run the shell either in your IDE or on the command line, then connect to the shell using
ssh -p 3000 admin@localhost
(password is password) and type help
to show the available commands
This example shows how to deploy the Vert.x Shell service available via Telnet as a packaged Vert.x service.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type help
to show the available commands
This example shows how to deploy the Vert.x Shell service available via Http as a packaged Vert.x service.
Run the shell either in your IDE or on the command line, then point your browser to
http://localhost:8080/shell.html
and type help
to show the available commands
This example shows a simple hello world command extending Vert.x Shell.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type helloworld
to run the command.
This example uses the Vert.x HTTP client to create a simple version of the wget
command. It shows how
a command can interract with other Vert.x APIs, in this case the HttpClient
.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type wget <url>
to run the command on the URL you like.
This example displays a list of the current JVM threads and mimics the OS top command. It shows how to push periodically data to the Shell.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type top
to run the top command, hit Ctrl-C when you want to quit.
This example prints on the screen, what the user types on his keyboard. It shows the usage of a command can capture keyboard events.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type echokeyboard
to run the command, then type some text, hit Ctrl-C when you are bored.
This example uses the Vert.x NetClient
to stream the the content a Starwars Ascii movie in the
Shell until Ctrl-C is pressed.
When the command is executes, it connects to a remote Telnet server that broadcasts an Ascii Starwars movie, the data sent by the server is just forwarded in the Shell screen. When the sockets closes, the command ends and the Shell takes the control again.
The commands sets an event handler on EventType.SIGINT
that reacts to Ctr-C key, this events just closes
the socket and terminates the commands.
Run the shell either in your IDE or on the command line, then connect to the shell using
telnet localhost 3000
and type starwars
. Hit Ctrl-C when you are done.
This examples uses the Vert.x Shell term server to broadcast the current host screen to the client until Ctrl-C is hit.
The TermServer provides only terminal simple terminal capabilities and the handler has total control of the user terminal, unlike the ShellServer that provides shell like features.