ct_netconfc:open / 1引发“异常错误:错误的参数”

时间:2017-10-10 07:28:29

标签: erlang ietf-netconf

我写了这个Erlang模块:

-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]).

编译,然后运行它:

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

我将参数格式化为open/1http://erlang.org/doc/man/ct_netconfc.html#open-1)的文档说明;仍然命令会给出错误。

有人可以帮我理解吗?

谢谢,

爱丽儿

1 个答案:

答案 0 :(得分:1)

实际需要user_dir选项。你需要像以下一样使用它:

-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]).

希望这会有所帮助:)