I just installed Erlang to my mac using these instructions. http://handyrailstips.com/blog_posts/12-installing-erlang-on-mac-os-x-lion-10-7
Installation worked alright, but when I fired up the Erlang R13B04 Eshell V5.7.5 I immediately started noticing problems - the shell isn't echoing the results of the commands! Actually I'm not even sure if the shell executes the commands at all. Can anyone help me with this?
Here's a sample output:
pallo:erlangstuff gro$ erl
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe][kernel-poll:false]
Eshell V5.7.5 (abort with ^G)
1> 1 + 1
1> dslakjdlksaj lksajkldsajkdsa
1> "fooo bar baz!"
1>
You have to finish the statement with a period:
Eshell V5.7.5 (abort with ^G)
1> 1+1.
2
2>
Related
I started the crashdump_viewer and started looking at my crashdump. Then at some point I got an error log. What does this mean and how do I fix it?
➜ Desktop erl
Erlang/OTP 21 [erts-10.3.5.11] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]
Eshell V10.3.5.11 (abort with ^G)
1> l(crashdump_viewer).
{module,crashdump_viewer}
2> crashdump_viewer:st
start/0 start/1 start_link/0 stop/0 stop_debug/0
2> crashdump_viewer:start
start/0 start/1 start_link/0
2> crashdump_viewer:start().
objc[26293]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fffa1eec3d8) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x1f551f50). One of the two will be used. Which one is undefined.
ok
3>
Erlang doesn't have classes, so the class in question probably has something to do with "the viewer" software. According to this, it's an Apple issue.
I want to implement a simple chat room in which two nodes can send message to each other synchronous. There is not a node that plays a role of server.
Can I use ! to send a message to another node, if i have the pid of the process on this node by function of spawn(Node,Module,Fun,Args)?
You can send to processes at another node just the same you would do with a process local to the same node. The trick is of course you need to have the process id. But you can also send to a process registered at another node by using the tuple {RegisteredName, NodeName}, e.g.
register(a, self()), {a, node()} ! foo.
will send a message to yourself.The same syntax works across nodes.
A more elaborate example
In the first shell:
erl -sname one
Erlang R15B01 (erts-5.9.1) [source] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
one#grannysmith)1> (one#grannysmith)1> register(hello_server, self()).
(one#grannysmith)2>
true
In the second shell:
erl -sname two
Erlang R15B01 (erts-5.9.1) [source] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
two#grannysmith)1> (one#grannysmith)1> {hello_server, 'one#grannysmith'} ! good_day.
good_day
(two#grannysmith)2>
And again in the first shell:
(one#grannysmith)2> flush().
Shell got good_day
ok
I got this error on my ubuntu when I run debugger:start().
Erlang R14B02 (erts-5.8.3) [source] [smp:4:4] [rq:4] [async-threads:0] [kernel-poll:false]
Eshell V5.8.3 (abort with ^G)
1> debugger:start().
=ERROR REPORT==== 14-Feb-2012::17:57:27 ===
ERROR: Could not find 'wxe_driver.so' in: /usr/local/lib/erlang/lib/wx-0.98.9/priv
{ok,<0.36.0>}
I want to know how to fix the error in order to use debugger ?
Are you running the default erlang running on ubuntu? Unfortunately there is no longer any erlang-wx package in ubuntu, see this for a discussion on why.
I would recommend downloading the deb package from here or just building erlang from source.
Could not solve this by myself
launched a new node A with ssh command
started a new node B
gen_tcp:connect/3 works on B, but rpc:call(B,gen_tcp,connect,Params) not works.
Both nodes are running on local laptop
and one node returns ok and the other node returns error.
I don't understand.
Anyone knows why?
~ $ssh allen#127.0.0.1 'erl -name loadtest#127.0.0.1 -detached -setcookie loadtest'
~ $erl -name allen#127.0.0.1 -setcookie loadtest
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.4 (abort with ^G)
(allen#127.0.0.1)1> gen_tcp:connect("www.google.com",80,[]).
{ok,#Port<0.630>}
(allen#127.0.0.1)2> rpc:call('loadtest#127.0.0.1',gen_tcp,connect,["www.google.com",80,[]]).
{error,nxdomain}
What is the best practice to accessing a single running mnesia node from another Erlang shell to only view data in the tables?
I tried opening two shells and pointing them to the same mnesia directory location which I realized was a very bad idea after finding this in the documentation.
-mnesia dir Directory. The name of the directory where all Mnesia data is stored. The name of the directory must be unique for the current node. Two nodes may, under no circumstances, share the same Mnesia directory. The results are totally unpredictable.
I think that easiest way is joining to remote shell. Just start erl with -remsh Node parameter
$ erl -sname foo
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.5 (abort with ^G)
(foo#hynek-notebook)1>
Another terminal:
$ erl -sname bar -remsh 'foo#hynek-notebook'
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.5 (abort with ^G)
(foo#hynek-notebook)1>
Another option is use powerful job control capability of erl (Press ^G)
$ erl -sname bar
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.5 (abort with ^G)
(bar#hynek-notebook)1>
User switch command
--> h
c [nn] - connect to job
i [nn] - interrupt job
k [nn] - kill job
j - list all jobs
s [shell] - start local shell
r [node [shell]] - start remote shell
q - quit erlang
? | h - this message
--> r 'foo#hynek-notebook'
--> j
1 {shell,start,[init]}
2* {'foo#hynek-notebook',shell,start,[]}
--> c
Eshell V5.7.5 (abort with ^G)
(foo#hynek-notebook)1>
User switch command
--> j
1 {shell,start,[init]}
2* {'foo#hynek-notebook',shell,start,[]}
--> c 1
(bar#hynek-notebook)1>
Note that you have to press Enter to show shell prompt if you are switching back to existing one.