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

送分小仙女□ 提交于 2019-12-13 03:12:49

问题


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:


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 :)



来源:https://stackoverflow.com/questions/46660902/ct-netconfcopen-1-raises-an-exception-error-bad-argument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!