ct_netconfc:open/1 raises an “exception error: bad

2019-08-22 04:13发布

I wrote this Erlang module:

-module(ncclient).
-export([open/0]).

open() -> 
    Host = {ssh, {192,168,30,11}},
    Port = {port, 830},
    User = {user, "admin"},
    Pass = {password, "admin"},
    ct_netconfc:open([Host, Port, User, Pass]).

Compiled, then ran it:

# erl
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [kernel-poll:false]

Eshell V9.1  (abort with ^G)
1> c(ncclient).
{ok,ncclient}
2> ncclient:open().
** exception error: bad argument
 in function  ets:select/2
    called as ets:select(ct_attributes,
                         [{{ct_conf,'$1','_','_','_',undefined,'_'},[],['$1']}])
 in call from ct_config:get_key_from_name/1 (ct_config.erl, line 575)
 in call from ct_util:does_connection_exist/3 (ct_util.erl, line 576)
 in call from ct_gen_conn:do_start/4 (ct_gen_conn.erl, line 223)
 in call from ct_netconfc:open/4 (ct_netconfc.erl, line 388)

I formatted the arguments as explains the documentation for open/1 (http://erlang.org/doc/man/ct_netconfc.html#open-1); still the commands gives back an error.

May someone help me to understand?

Thanks,

Ariel

1条回答
乱世女痞
2楼-- · 2019-08-22 04:52

The user_dir option is actually required. you need to use it like:

-module(ncclient).
-export([open/0]).

open() -> 
  Host = {ssh, {192,168,30,11}},
  Port = {port, 830},
  User = {user, "admin"},
  Pass = {password, "admin"},
  Dir = {user_dir, "/home/username"},
  ct_netconfc:open([Host, Port, User, Pass, Dir]).

Hope this helps :)

查看更多
登录 后发表回答