urbiscript comes with a set of tools, two of which being of particular importance:
Please, first make sure that these tools are properly installed. If you encounter problems, please see the frequently asked questions (Section 14), and the detailed installation instructions (paragraph 13).
There are several means to interact with a server spawned by urbi, see Section 19.3 for details. First of all, you may use the options ‘-e’/‘--expression code ’ and ‘-f’/‘--file file ’ to send some code or the contents of some file to the newly run server. The option ‘q’/‘--quiet’ discards the banner.
You may combine any number of these options, but beware that being event-driven, the server does not “know” when a program ends. Therefore, batch programs should end by calling shutdown. Using a Unix shell:
# A classical program.
$ urbi -q -e ’echo("Hello, World!");’ -e ’shutdown;’
[00000004] *** Hello, World!
If you are running Windows, then, since the quotation rules differ, run:
# A classical program.
$ urbi -q -e "echo(""Hello, World!"");" -e "shutdown;"
[00000004] *** Hello, World!
To run an interactive session, use option ‘-i’/‘--interactive’. Like most interactive interpreters, Urbi will evaluate the given commands and print out the results.
$ urbi -i
[00000825] *** Urbi version 3.x.y
1+2;
[00001200] 3
shutdown;
The output from the server is prefixed by a number surrounded by square brackets: this is the date (in milliseconds since the server was launched) at which that line was sent by the server. This is useful at occasions, since Urbi is meant to run many parallel commands. Since these timestamps are irrelevant in most examples, they will often be filled with zeroes through this documentation.
Under Unix, the program rlwrap provides additional services (history of commands, advanced command line edition etc.); run ‘rlwrap urbi -i’.
In either case the server can also be made available for network-based interactions using option ‘--port port ’. Note that while shutdown asks the server to quit, quit only quits one interactive session. In the following example (under Unix) the server is still available for other, possibly concurrent, sessions.
$ urbi --port 54000 &
[1] 77024
$ telnet localhost 54000
Trying 127.0.0.1...
Connected to localhost.
Escape character is ’^]’.
[00004816] *** Urbi version 3.x.y
12345679*8;
[00018032] 98765432
quit;
Connection closed by foreign host.
Under Windows, instead of using telnet, you may use Gostai Console (part of the package), which provides a Graphical User Interface to a network-connection to an Urbi server. To launch the server, run:
and to launch the client, click on Gostai Console which is installed by the installer.
Then, the interaction proceeds in the Gostai Console windows. Specify the host name and port to use (‘127.0.0.1:54000’) in the text field in the top of the window and click on the right to start the connection.
The program urbi-send (see Section 19.8) provides a nice interface to send batches of instructions (and/or files) to a running server.
$ urbi-send -P 54000 -e "1+2*3;" -Q
[00018032] 7
# Have the server shutdown;
$ urbi-send -P 54000 -e "shutdown;"
You can now send commands to your Urbi server. If at any point you get lost, or want a fresh start, you can simply close and reopen your connection to the server to get a clean environment. In some cases, particularly if you made global changes in the environment, it is simpler to start anew: shut your current server down using the command shutdown, and spawn a new one. In interactive mode you can also use the shortcut sequence Ctrl-D, like in many other interpreters.
In case of a foreground task preventing you to execute other commands, you can use Ctrl-C to kill the foreground task, clear queued commands and restore interactive mode.
You are now ready to proceed to the urbiscript tutorial: see Listing I.
Enjoy!