1

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

Ariel Otilibili
  • 260
  • 1
  • 6
  • Try running `ct_util:start()` first. That function seems to create the ETS tables that `ct_netconfc` expects to find. – legoscia Oct 10 '17 at 14:15
  • `ct_util:start()` before `ct_netconfc:open([Host, Port, User, Pass])` gives: `** exception exit: {error,not_installed} in function ct_util:start/3 (ct_util.erl, line 112) in call from ncclient:open/0 (ncclient.erl, line 10)` – Ariel Otilibili Oct 11 '17 at 08:51
  • How did you resolve the issue? Please share it for the benefit of the community. – Bhuvan Nov 02 '22 at 03:07

1 Answers1

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

codeadict
  • 2,643
  • 1
  • 15
  • 11
  • :-( I copied my keys to that host with `ssh-copy-id -p 830 admin@192.168.30.11`. As `Dir`, I used `{user_dir, "~/.ssh"}`. Still got the same error that before. – Ariel Otilibili Oct 11 '17 at 08:43
  • 1
    The same error than before: `** 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)` – Ariel Otilibili Oct 11 '17 at 13:14