erlang

How to use Erlang file:read_file_info permissions/mode info?

岁酱吖の 提交于 2019-12-11 02:55:38
问题 The Erlang docs for file:read_file_info/1 state "file permissions [are] the sum" and "other bits...may be set", not instilling confidence. And, Google has not been my friend here. I'm looking to take the mode returned by file:read_file_info/1 , e.g. 33188 , on a Linux machine and convert it into something more human readable and/or recognizable, like rw-r--r-- or 644 . Any tips, links, or directions greatly appreciated. 回答1: The short way: io_lib:format("~.8B", [Mode]). ... or: io_lib:format(

Linux(CENTOS7) RabbitMq安装

懵懂的女人 提交于 2019-12-11 02:49:30
RabbitMQ是一个在AMQP协议标准基础上完整的,可服用的企业消息系统。它遵循Mozilla Public License开源协议,采用 Erlang 实现的工业级的消息队列(MQ)服务器,Rabbit MQ 是建立在Erlang OTP平台上。 1、安装Erlang   因为rabbitMQ是Erlang语言编写的,所以我们首先需要安装Erlang rpm -Uvh http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpm 2、安装rabbitMQ-server rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.6/rabbitmq-server-3.5.6-1.noarch.rpm 3、查看是否安装成功 rpm -qa|grep rabbitmq ​​ 4、开启rabbit-server 开启:service rabbitmq-server start 关闭:service rabbitmq-server stop ​ 这样虽然我们已经将rabbitmq的服务正常启动了,但是我们在物理机的浏览器中输入ip:15672时,并不能连接,因为我们还没有配置维护插件和开启远程连接 5、查看状态

Tail recursion in Erlang

ⅰ亾dé卋堺 提交于 2019-12-11 02:41:56
问题 I am really struggling to understand tail recursion in Erlang. I have the following eunit test: db_write_many_test() -> Db = db:new(), Db1 = db:write(francesco, london, Db), Db2 = db:write(lelle, stockholm, Db1), ?assertEqual([{lelle, stockholm},{francesco, london}], Db2). And here is my implementation: -module(db) . -include_lib("eunit/include/eunit.hrl"). -export([new/0,write/3]). new() -> []. write(Key, Value, Database) -> Record = {Key, Value}, [Record|append(Database)]. append([H|T]) ->

can I trap exit(self(), kill)?

匆匆过客 提交于 2019-12-11 02:39:08
问题 when i read an artical from learnyousomeerlang.com,I got a question. http://learnyousomeerlang.com/errors-and-processes It says that: Exception source: exit(self(), kill) Untrapped Result: ** exception exit: killed Trapped Result: ** exception exit: killed Oops, look at that. It seems like this one is actually impossible to trap. Let's check something. but it does not comply with what I test with the code blow: -module(trapexit). -compile(export_all). self_kill_exit()-> process_flag(trap_exit

Installing up-to-date version of Erlang on RHEL7

狂风中的少年 提交于 2019-12-11 02:37:50
问题 I'm trying to install an up to date (version 20.3 at the moment of the writing) Erlang distribution into RHEL7 (release 7.5 to be exact). Google tells me the up-to-date Erlang distribution is maintained by Erlang Solutions at https://packages.erlang-solutions.com/ (thanks!) There you also find instructions how to add the repository so that the Erlang can be installed with a package manager: Installation using repository Adding repository entry To add Erlang Solutions repository (including our

RabbitMQ的安装与配置

白昼怎懂夜的黑 提交于 2019-12-11 02:28:56
官网: https://www.rabbitmq.com/ 一. 配置ErLang环境:   1. 安装支持库: apt-get -y install libncurses5-devapt-get -y install make g++ gcc libpcre3 libpcrecpp* libpcre3-dev libssl-dev autoconf automake libtool nfs-kernel-server libncurses5-dev libaio.dev ruby-dev rubygems vim   2. 将ErLang安装包上传或下载: http://erlang.org/download/otp_src_20.0.tar.gz   3. 解压:   检查JDK:java -version tar xzvf /srv/ftp/otp_src_22.0.tar.gz -C /usr/local/src/    #解压mkdir -p /usr/local/erlang                      #编译后存储目录cd /usr/local/src/otp_src_22.0/                   #进入源代码目录./configure --prefix=/usr/local/erlang               

How to keep track of children processes in erlang?

痴心易碎 提交于 2019-12-11 02:26:28
问题 I have a static list of "hosts" with their info, and a dynamic list of "host agents". Each host has one and only one agent for as long as it connects to the server by a TCP connection. As the host may or may not be connected, its agent process may or may not be started. When a TCP packet arrives with the host ID, I need to find out if the "agent" of this host is started or not. Connection is responsible for receive and send data from tcp socket, parse the data to find out which host it should

Erl cannot connect to local EPMD. Why?

扶醉桌前 提交于 2019-12-11 02:22:31
问题 erl Erlang R14B04 (erts-5.8.5) [source] [64-bit] [rq:1] [async-threads:0] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) [root@ip-10-101-61-85 ec2-user]# erl -sname foo {error_logger,{{2012,12,7},{3,17,8}},"Protocol: ~p: register error: ~p~n",["inet_tcp",{{badmatch,{error,epmd_close}},[{inet_tcp_dist,listen,1},{net_kernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}]} {error_logger,{{2012,12,7

ERLANG - Pattern Matching

泄露秘密 提交于 2019-12-11 02:09:28
问题 I have a variable: Data = [[<<>>, [<<"10">>,<<"171">>], [<<"112">>,<<"Gen20267">>], [<<"52">>,<<"20100812-06:32:30.687">>]] I am trying to pattern match for two specific cases.. One where anything that resembles the outside structure - simply [] Anything inside goes I have tried [ _ ] but no go? The Second, for a specific pattern inside, like when I see a <<"10">> or <<"112">> or <<"52">> then I am going to take the right side which is the actual data into an atom. Basically the <<"10">> or <

Merge inner lists of a list erlang

丶灬走出姿态 提交于 2019-12-11 01:59:06
问题 I have a list L L = [L1, L2, L3,...]. where L1, L2, L3.. are themselves lists, like so: L1 = [{k1, 10}, {k2, 20}, {k3, 30}, {k4, 20.9}, {k6, "Hello world"}] L2 = [{k1, 90}, {k2, 210}, {k3, 60}, {k4, 66.9}, {k6, "Hello universe"}] L3 = [...] now I want a result combined list as : FinalList = [ {k1, [10, 90, ...]}, % '...' denotes values from other lists {k2, [20, 210, ...]}, {K3, [30, 60, ...]}, {k4, [20.9, 66.9, ...]}, {K6, ["Hello world", "Hello universe", ...]} ] I can merge using my Old