aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_test_cli.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2016-01-28 12:17:59 +0100
committerHans Nilsson <[email protected]>2016-02-08 14:47:15 +0100
commit60f828c89fde5fc9fccfa6305512d9458f5293c4 (patch)
tree33c171beccffd6c906117fbce075ac6b554663a5 /lib/ssh/test/ssh_test_cli.erl
parentb62cd7fd5a922cfdff05bfba9512ce36ce100116 (diff)
downloadotp-60f828c89fde5fc9fccfa6305512d9458f5293c4.tar.gz
otp-60f828c89fde5fc9fccfa6305512d9458f5293c4.tar.bz2
otp-60f828c89fde5fc9fccfa6305512d9458f5293c4.zip
ssh: fixes port_command failure on WIndows in ssh_test_cli.erl
Diffstat (limited to 'lib/ssh/test/ssh_test_cli.erl')
-rw-r--r--lib/ssh/test/ssh_test_cli.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/ssh/test/ssh_test_cli.erl b/lib/ssh/test/ssh_test_cli.erl
index cd9ad5f2ff..697ddb730d 100644
--- a/lib/ssh/test/ssh_test_cli.erl
+++ b/lib/ssh/test/ssh_test_cli.erl
@@ -4,20 +4,25 @@
-record(state, {
type,
+ tmpdir,
id,
ref,
port
}).
-init([Type]) ->
- {ok, #state{type = Type}}.
+
+init([Type]) -> init([Type,"/tmp"]);
+
+init([Type,TmpDir]) ->
+ {ok, #state{type = Type,
+ tmpdir = TmpDir}}.
handle_msg({ssh_channel_up, Id, Ref}, S) ->
User = get_ssh_user(Ref),
ok = ssh_connection:send(Ref,
Id,
<< "\r\nYou are accessing a dummy, type \"q\" to exit\r\n\n" >>),
- Port = run_portprog(User, S#state.type),
+ Port = run_portprog(User, S#state.type, S#state.tmpdir),
{ok, S#state{port = Port, id = Id, ref = Ref}};
handle_msg({Port, {data, Data}}, S = #state{port = Port}) ->
@@ -68,10 +73,10 @@ handle_ssh_msg({ssh_cm, _, {exit_signal, Id, _, _, _}},
terminate(_Why, _S) ->
nop.
-run_portprog(User, cli) ->
+run_portprog(User, cli, TmpDir) ->
Pty_bin = os:find_executable("cat"),
open_port({spawn_executable, Pty_bin},
- [stream, {cd, "/tmp"}, {env, [{"USER", User}]},
+ [stream, {cd, TmpDir}, {env, [{"USER", User}]},
{args, []}, binary,
exit_status, use_stdio, stderr_to_stdout]).