apread(ChannelPid,Handle,Position,Len)->{async,N}|Error
Types:
ChannelPid = pid()
Handle = term()
Position = Len = integer()
Error = {error, reason()}
N = term()
The apread/4 function reads from a specified position, combining the position/3 and aread/3
functions.
apwrite(ChannelPid,Handle,Position,Data)->{async,N}|Error
Types:
ChannelPid = pid()
Handle = term()
Position = integer()
Data = binary()
Error = {error, reason()}
N = term()
The apwrite/4 function writes to a specified position, combining the position/3 and awrite/3
functions.
aread(ChannelPid,Handle,Len)->{async,N}|Error
Types:
ChannelPid = pid()
Handle = term()
Len = integer()
Error = {error, reason()}
N = term()
Reads from an open file, without waiting for the result. If the handle is valid, the function
returns {async,N}, where N is a term guaranteed to be unique between calls of aread. The actual
data is sent as a message to the calling process. This message has the form {async_reply,N,Result}, where Result is the result from the read, either {ok,Data}, eof, or {error,reason()}.
awrite(ChannelPid,Handle,Data)->{async,N}|Error
Types:
ChannelPid = pid()
Handle = term()
Data = binary()
Error = {error, reason()}
N = term()
Writes to an open file, without waiting for the result. If the handle is valid, the function
returns {async,N}, where N is a term guaranteed to be unique between calls of awrite. The result
of the write operation is sent as a message to the calling process. This message has the form
{async_reply,N,Result}, where Result is the result from the write, either ok, or {error,reason()}.
close(ChannelPid,Handle)->ok|Errorclose(ChannelPid,Handle,Timeout)->ok|Error
Types:
ChannelPid = pid()
Handle = term()
Timeout = timeout()
Error = {error, reason()}
Closes a handle to an open file or directory on the server.
delete(ChannelPid,Name)->ok|Errordelete(ChannelPid,Name,Timeout)->ok|Error
Types:
ChannelPid = pid()
Name = string()
Timeout = timeout()
Error = {error, reason()}
Deletes the file specified by Name.
del_dir(ChannelPid,Name)->ok|Errordel_dir(ChannelPid,Name,Timeout)->ok|Error
Types:
ChannelPid = pid()
Name = string()
Timeout = timeout()
Error = {error, reason()}
Deletes a directory specified by Name. The directory must be empty before it can be successfully
deleted.
list_dir(ChannelPid,Path)->{ok,FileNames}|Errorlist_dir(ChannelPid,Path,Timeout)->{ok,FileNames}|Error
Types:
ChannelPid = pid()
Path = string()
Timeout = timeout()
FileNames = [FileName]
FileName = string()
Error = {error, reason()}
Lists the given directory on the server, returning the filenames as a list of strings.
make_dir(ChannelPid,Name)->ok|Errormake_dir(ChannelPid,Name,Timeout)->ok|Error
Types:
ChannelPid = pid()
Name = string()
Timeout = timeout()
Error = {error, reason()}
Creates a directory specified by Name. Name must be a full path to a new directory. The directory
can only be created in an existing directory.
make_symlink(ChannelPid,Name,Target)->ok|Errormake_symlink(ChannelPid,Name,Target,Timeout)->ok|Error
Types:
ChannelPid = pid()
Name = Target = string()
Timeout = timeout()
Error = {error, reason()}
Creates a symbolic link pointing to Target with the name Name.
open(ChannelPid,Name,Mode)->{ok,Handle}|Erroropen(ChannelPid,Name,Mode,Timeout)->{ok,Handle}|Error
Types:
ChannelPid = pid()
Name = string()
Mode = [read | write | append | binary | raw]
Timeout = timeout()
Handle = term()
Error = {error, reason()}
Opens a file on the server and returns a handle, which can be used for reading or writing.
opendir(ChannelPid,Path)->{ok,Handle}|Erroropendir(ChannelPid,Path,Timeout)->{ok,Handle}|Error
Types:
ChannelPid = pid()
Path = string()
Timeout = timeout()
Handle = term()
Error = {error, reason()}
Opens a handle to a directory on the server. The handle can be used for reading directory
contents.
open_tar(ChannelPid,Path,Mode)->{ok,Handle}|Erroropen_tar(ChannelPid,Path,Mode,Timeout)->{ok,Handle}|Error
Types:
ChannelPid = pid()
Path = string()
Mode = [read | write | {crypto, tar_crypto_spec()}]
Timeout = timeout()
Handle = term()
Error = {error, reason()}
Opens a handle to a tar file on the server, associated with ChannelPid. The handle can be used for
remote tar creation and extraction. The actual writing and reading is performed by calls to
erl_tar:add/3,4 and erl_tar:extract/2. Note: The erl_tar:init/3 function should not be called,
that one is called by this open_tar function.
For code examples see Section SFTP Client with TAR Compression in the ssh Users Guide.
The crypto mode option is explained in the data types section above, see Crypto operations for
open_tar. Encryption is assumed if the Mode contains write, and decryption if the Mode contains
read.
position(ChannelPid,Handle,Location)->
{ok, NewPosition} | Error
position(ChannelPid,Handle,Location,Timeout)->
{ok, NewPosition} | Error
Types:
ChannelPid = pid()
Handle = term()
Location =
Offset |
{bof, Offset} |
{cur, Offset} |
{eof, Offset} |
bof | cur | eof
Timeout = timeout()
Offset = NewPosition = integer()
Error = {error, reason()}
Sets the file position of the file referenced by Handle. Returns {ok,NewPosition} (as an absolute
offset) if successful, otherwise {error,reason()}. Location is one of the following:
Offset:
The same as {bof,Offset}.
{bof,Offset}:
Absolute offset.
{cur,Offset}:
Offset from the current position.
{eof,Offset}:
Offset from the end of file.
bof|cur|eof:
The same as eariler with Offset 0, that is, {bof,0}|{cur,0}|{eof,0}.
pread(ChannelPid,Handle,Position,Len)->
{ok, Data} | eof | Error
pread(ChannelPid,Handle,Position,Len,Timeout)->
{ok, Data} | eof | Error
Types:
ChannelPid = pid()
Handle = term()
Position = Len = integer()
Timeout = timeout()
Data = string() | binary()
Error = {error, reason()}
The pread/3,4 function reads from a specified position, combining the position/3 and read/3,4
functions.
pwrite(ChannelPid,Handle,Position,Data)->ok|Errorpwrite(ChannelPid,Handle,Position,Data,Timeout)->ok|Error
Types:
ChannelPid = pid()
Handle = term()
Position = integer()
Data = iolist()
Timeout = timeout()
Error = {error, reason()}
The pwrite/3,4 function writes to a specified position, combining the position/3 and write/3,4
functions.
read(ChannelPid,Handle,Len)->{ok,Data}|eof|Errorread(ChannelPid,Handle,Len,Timeout)->{ok,Data}|eof|Error
Types:
ChannelPid = pid()
Handle = term()
Len = integer()
Timeout = timeout()
Data = string() | binary()
Error = {error, reason()}
Reads Len bytes from the file referenced by Handle. Returns {ok,Data}, eof, or {error,reason()}.
If the file is opened with binary, Data is a binary, otherwise it is a string.
If the file is read past eof, only the remaining bytes are read and returned. If no bytes are
read, eof is returned.
read_file(ChannelPid,File)->{ok,Data}|Errorread_file(ChannelPid,File,Timeout)->{ok,Data}|Error
Types:
ChannelPid = pid()
File = string()
Data = binary()
Timeout = timeout()
Error = {error, reason()}
Reads a file from the server, and returns the data in a binary.
read_file_info(ChannelPid,Name)->{ok,FileInfo}|Errorread_file_info(ChannelPid,Name,Timeout)->
{ok, FileInfo} | Error
Types:
ChannelPid = pid()
Name = string()
Timeout = timeout()
FileInfo = file:file_info()
Error = {error, reason()}
Returns a file_info record from the file system object specified by Name or Handle. See
file:read_file_info/2 for information about the record.
Depending on the underlying OS:es links might be followed and info on the final file, directory
etc is returned. See read_link_info/2 on how to get information on links instead.
read_link(ChannelPid,Name)->{ok,Target}|Errorread_link(ChannelPid,Name,Timeout)->{ok,Target}|Error
Types:
ChannelPid = pid()
Name = Target = string()
Timeout = timeout()
Error = {error, reason()}
Reads the link target from the symbolic link specified by name.
read_link_info(ChannelPid,Name)->{ok,FileInfo}|Errorread_link_info(ChannelPid,Name,Timeout)->
{ok, FileInfo} | Error
Types:
ChannelPid = pid()
Name = string()
FileInfo = file:file_info()
Timeout = timeout()
Error = {error, reason()}
Returns a file_info record from the symbolic link specified by Name or Handle. See
file:read_link_info/2 for information about the record.
rename(ChannelPid,OldName,NewName)->ok|Errorrename(ChannelPid,OldName,NewName,Timeout)->ok|Error
Types:
ChannelPid = pid()
OldName = NewName = string()
Timeout = timeout()
Error = {error, reason()}
Renames a file named OldName and gives it the name NewName.
start_channel(ConnectionRef)->start_channel(ConnectionRef,SftpOptions)->{ok,ChannelPid}|Errorstart_channel(Host)->start_channel(Host,Options)->start_channel(Host,Port,Options)->start_channel(TcpSocket)->start_channel(TcpSocket,Options)->{ok,ChannelPid,ConnectionRef}|Error
Types:
Host = ssh:host()
Port = inet:port_number()
TcpSocket = ssh:open_socket()
Options = [ sftp_option() | ssh:client_option() ]
SftpOptions = [ sftp_option() ]
ChannelPid = pid()
ConnectionRef = ssh:connection_ref()
Error = {error, reason()}
If no connection reference is provided, a connection is set up, and the new connection is
returned. An SSH channel process is started to handle the communication with the SFTP server. The
returned pid for this process is to be used as input to all other API functions in this module.
Options:
{timeout,timeout()}:
There are two ways to set a timeout for the underlying ssh connection:
* If the connection timeout option connect_timeout is set, that value is used also for the
negotiation timeout and this option (timeout) is ignored.
* Otherwise, this option (timeout) is used as the negotiation timeout only and there is no
connection timeout set
The value defaults to infinity.
{sftp_vsn,integer()}:
Desired SFTP protocol version. The actual version is the minimum of the desired version and
the maximum supported versions by the SFTP server.
All other options are directly passed to ssh:connect/3 or ignored if a connection is already
provided.
stop_channel(ChannelPid)->ok
Types:
ChannelPid = pid()
Stops an SFTP channel. Does not close the SSH connection. Use ssh:close/1 to close it.
write(ChannelPid,Handle,Data)->ok|Errorwrite(ChannelPid,Handle,Data,Timeout)->ok|Error
Types:
ChannelPid = pid()
Handle = term()
Data = iodata()
Timeout = timeout()
Error = {error, reason()}
Writes data to the file referenced by Handle. The file is to be opened with write or append flag.
Returns ok if successful or {error,reason()} otherwise.
write_file(ChannelPid,File,Data)->ok|Errorwrite_file(ChannelPid,File,Data,Timeout)->ok|Error
Types:
ChannelPid = pid()
File = string()
Data = iodata()
Timeout = timeout()
Error = {error, reason()}
Writes a file to the server. The file is created if it does not exist but overwritten if it
exists.
write_file_info(ChannelPid,Name,FileInfo)->ok|Errorwrite_file_info(ChannelPid,Name,FileInfo,Timeout)->ok|Error
Types:
ChannelPid = pid()
Name = string()
FileInfo = file:file_info()
Timeout = timeout()
Error = {error, reason()}
Writes file information from a file_info record to the file specified by Name. See
file:write_file_info/[2,3] for information about the record.
Ericsson AB ssh 4.13 ssh_sftp(3erl)