[erlang-questions] Common test: ct_ssh usage?
tom kelly
ttom.kelly@REDACTED
Sat Aug 14 20:49:10 CEST 2010
Hi Mikkel,
I've used ct_ssh in the past and found it to be an extremely useful wrapper
for the ssh application!
If I create a config file (and call it "ssh.config") for common test with
the following entry:
{nodeICanSshTo,[
{ssh,"127.0.0.1"},
{username,"myName"},
{password,"letMeIn"}
]}.
Then from an erlang shell I can:
1> ct:install([{config,["ssh.config"]}]).
ok
2> ct:start_interactive().
<0.43.0>
3> ct:get_config({nodeICanSshTo).
[{ssh,"127.0.0.1"},{username,"myName"},{password,"letMeIn"}]
4> {ok,A} = ct_ssh:connect(nodeICanSshTo).
{ok,<0.53.0>}
5> {ok,B} = ct_ssh:session_open(A).
{ok,0}
6>
If you're using ct:run there's no need for the "install" and
"start_interactive" calls, I've just used interactive mode here for
demonstration.
Maybe you've got this far already? If this doesn't help include your config
file data next time.
//Tom.
On Sat, Aug 14, 2010 at 10:17 AM, Mikkel Jensen <emailos@REDACTED> wrote:
> Hi
>
> Im having a hard time using ct_ssh to just create a simple connection. This
> shouldn't be hard, but for some reason it is. I have been using
> http://www.erlang.org/doc/man/ct_ssh.html as the base of my efforts. My
> attempts at making a connection is shown below.
>
> If anyone could give me any tips or pointers to get me started, it would be
> much appreciated!
>
>
> 1. -module(simple).
> 2. -export([run/0]).
> 3.
> 4. -import(ct_ssh).
> 5. -import(ct_util).
> 6.
> 7. run() ->
> 8. ok = ct:require(mynodename,{sec,[ssh,"127.0.0.1"]}),
> 9. {ok, Handle} = ct_ssh:connect(mynodename),
> 10. Handle.
> 11.
> 12.
> 13. ERROR:
> 14. ------
> 15.
> 16. 1> simple:run().
> 17. ** exception error: bad argument
> 18. in function ct_util:call/1
> 19. in call from simple:run/0
> 20. 2> crypto:start().
> 21. ok
> 22. 3> ssh:start().
> 23. ok
> 24. 4> simple:run().
> 25. ** exception error: bad argument
> 26. in function ct_util:call/1
> 27. in call from simple:run/0
> 28.
>
>
>
>
> 1. -module(solossh).
> 2. -export([soloconnect/0]).
> 3. -import(ct_ssh).
> 4.
> 5. soloconnect() ->
> 6. {ok, Handle} = ct_ssh:connect(host, ssh, [{ssh, "127.0.0.1"},
> {port, "22"}, {user, "testserver"}, {password, "testpass"}]),
> 7. Handle.
> 8.
> 9.
> 10. error
> 11. ------
> 12.
> 13. 1> solossh:soloconnect().
> 14. ** exception error: bad argument
> 15. in function ets:select/2
> 16. called as ets:select(ct_attributes,
> 17. [{{ct_conf,'_','$2','$1',host,'_'},[],[{
> {'$1','$2'}}]}])
> 18. in call from ct_util:lookup_name/1
> 19. in call from ct_util:lookup_config/1
> 20. in call from ct_util:get_config/3
> 21. in call from ct_ssh:connect/3
> 22. in call from solossh:soloconnect/0
>
More information about the erlang-questions
mailing list