[erlang-questions] SFTP

Karolis Petrauskas k.petrauskas@REDACTED
Mon Jan 30 13:55:32 CET 2017


Hello,

I'm trying to use erlang's sftp server and client. In the example
bellow, i use erlang for both: the server and the client. For some
reason, i can't open some files.

    43> ssh_sftp:list_dir(Ch, ".").
    {ok,["other.txt","some.txt"]}

    44> ssh_sftp:read_file(Ch, "some.txt").
    {ok,<<"some.txt contents">>}

    45> ssh_sftp:read_file(Ch, "other.txt").
    {error,no_such_file}

I was able to read both files with absolute file names specified, but
in my case I should not depend on the absolute paths. I could use the
absolute file names when opening files, if I could get the current
working directory from the server, but I cant find any function for
that.

The server behaviour is also a unclear to me. I can't set the cwd, if
the root option is used when starting the daemon. I have tried various
combinations of root/cwd (cwd is relative to root, or absolute on the
target file system), the sftp client always logins with / as its
current working directory.

In my case, I use the sftpd only for testing the sftp client in CT.
I'm working on Erlang/OTP 19 [erts-8.2].

Would be thankful for any pointers.

Karolis



More information about the erlang-questions mailing list