I just downloaded Erlang using apt-get onto Ubuntu 10.10. How do I run the examples that come with Erlang (the examples you can get through apt-get install erlang-examples). I tried going to the directory where they were stored and compiling ball.erl, but I got this error:
ball.bea#: error writing file
error
The directory where those examples are stored isn’t writeable by normal users. To compile a
.erlfile, the compiler needs to be able to write out the compiled.beamfile.One way around this is to copy the files to a directory you can write to and compile them there:
You need the
erlang-devpackage installed for that to work.You can run the
ballexample like so:ballhere is the module name, and the Erlang emulator defaults to calling thestart/0function in that module, which is correct in this case.You don’t actually have to compile these examples, however. The Ubuntu
erlang-examplespackage ships with them already compiled:After closing the GUI window in each, say
q().to get out of the emulator. This may seem weird to you until you realize that everything about Erlang is designed with long uptimes in mind. The mere fact that the last process the emulator was running has stopped isn’t enough reason for the BEAM emulator to shut itself down. Something else might be started in that same emulator later, after all.