Next

Prev

Prev-tail

Tail

Up

Chapter 2
Getting Started

urbiscript comes with a set of tools, two of which being of particular importance:

urbi
launches an Urbi server. There are several means to interact with it, which we will see later.
urbi-launch
runs Urbi components, the UObjects, and connects them to an Urbi server.

Please, first make sure that these tools are properly installed. If you encounter problems, please see the frequently asked questions (Section 16), and the detailed installation instructions (Listing 15).

 
# Make sure urbi is properly installed. 
$ urbi --version 
Urbi Kernel version preview/2.0/beta3-425 rev. 000913e 
Copyright (C) 2005-2010 Gostai SAS. 
 
URBI SDK Remote version preview/1.6/beta1-666 rev. 92ec3b4 
Copyright (C) 2004-2010 Gostai SAS. 
 
Libport version preview/1.0/beta1-1048 rev. f1c5170 
Copyright (C) 2005-2010 Gostai SAS.  

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!  
Listing 2.1: A batch session under Unix.

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!  
Listing 2.2: A batch session under Windows.

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 
[00000987] *** ******************************************************** 
[00000990] *** Urbi SDK version 2.0.3 rev. d6a568d 
[00001111] *** Copyright (C) 2005-2010 Gostai S.A.S. 
[00001111] *** 
[00001111] *** This program comes with ABSOLUTELY NO WARRANTY.  It can 
[00001112] *** be used under certain conditions.  Type license;’, 
[00001112] *** authors;’, or copyright; for more information. 
[00001112] *** 
[00001112] *** Check our community site: http://www.urbiforge.org. 
[00001112] *** ******************************************************** 
1+2; 
[00001200] 3 
shutdown;  
Listing 2.3: An interactive session under Unix.

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. But 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 ^]. 
[00000987] *** ******************************************************** 
[00000990] *** Urbi SDK version 2.0.3 rev. d6a568d 
[00001111] *** Copyright (C) 2005-2010 Gostai S.A.S. 
[00001111] *** 
[00001111] *** This program comes with ABSOLUTELY NO WARRANTY.  It can 
[00001112] *** be used under certain conditions.  Type license;’, 
[00001112] *** authors;’, or copyright; for more information. 
[00001112] *** 
[00001112] *** Check our community site: http://www.urbiforge.org. 
[00001112] *** ******************************************************** 
12345679*8; 
[00018032] 98765432 
quit;  
Listing 2.4: An interactive session under Unix.

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:

 
C:\...> start urbi --port 54000  
Listing 2.5: Starting an interactive session under Windows.

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.

PIC

The program urbi-send (see Section 19.6) 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 II.

Enjoy!