%Net.SSH.SFTP
class %Net.SSH.SFTP extends %Library.RegisteredObject
A wrapper object for an SFTP session running over and existing SSH connection. Use the OpenSFTP() method of a previously connected and authenticated %Net.SSH.Session to instantiate a valid SFTP object for use.You should NOT create instances of %Net.SSH.SFTP directly!
NOTE: CacheSSH is currently not supported on OpenVMS platforms.
Property Inventory
Method Inventory
- %OnClose()
- CloseSFTP()
- Delete()
- Dir()
- DirEnum()
- FileInfo()
- Get()
- GetBufferSize()
- GetStream()
- H2UTCFileTime()
- MkDir()
- Permissions2Text()
- Put()
- PutStream()
- Rename()
- RmDir()
- SetBufferSize()
- SetFileTime()
- SetOwnerAndGroup()
- SetPermissions()
- SetSize()
- SymLink()
- Test()
- TestPut()
- Touch()
- UTCFileTime2H()
Properties
property SSH as %Net.SSH.Session;
SSH Session that hosts this SFTP session.
Property methods: SSHGet(), SSHGetSwizzled(), SSHIsValid(), SSHNewObject(), SSHSet()
property Version as %Integer;
SFTP Remote Server Version
Property methods: VersionDisplayToLogical(), VersionGet(), VersionIsValid(), VersionLogicalToDisplay(), VersionNormalize(), VersionSet()
Methods
method %OnClose() as %Status
Clean up any resources
method CloseSFTP() as %Status
Close the SFTP session
Delete a file on the remote server
method Dir(directory As %String, ByRef contents, spec As %String = "", dotFiles As %Boolean = 0) as %Status
Enumerate the contents of a directory. Populates the contents array with $LIST entries for
each file in the directory, subscripted by a integer sequence, the $LIST is composed in the same
format as with the FileInfo() method.
()
The optional spec parameter allows for wildcards when searching the directory. The wildcards that can be used are as follows:
The optional spec parameter allows for wildcards when searching the directory. The wildcards that can be used are as follows:
- *: Match zero or more characters
- ?: Match exactly one character
*.txt journal_???.* 201?-??-??.log
method DirEnum(directory As %String, oref As %RegisteredObject, method As %String) as %Status
Enumerate the contents of a directory by calling the specified instance method once for each entry
in the directory. The signature of the callback should take two arguments, first an integer
sequence number and secondly a $LIST composed in the same format as with the FileInfo() method
(see FileInfo).
Gets information about a file. On return, info is a $LIST containing:
1) Filename
2) Size
3) File type
P: Named pipe (FIFO)
C: Character special
D: Directory
B: Block special
F: Regular file
L: Symbolic link
S: Socket
U: Unknown
4) Permissions
5) UID
6) GID
7) Last Access Time
8) Last Modification Time
Depending on the remote system, some information may not be available and
will be indicated by a null list element.
method Get(remote As %String, local As %String, localmode As %String = "0600", append As %Boolean = 0) as %Status
Get a file from the remote system, storing it in the local file system with the specified mode (access).
Gets the transfer buffer size for SFTP operations (in bytes).
method GetStream(remote As %String, ByRef stream As %Stream.Object, append As %Boolean = 0) as %Status
Get a file from the remote system, storing it in the stream.
If stream not defined on entry it will create a stream for this automatically. If stream
is a file stream we will just link to the file we created.
Convert $HOROLOG to UNIX file time; note that UNIX time is the number of seconds since Midnight Jan 1, 1970
which has a $HOROLOG date of 47117,0
Create a new directory on the remote server, with the specified file mode (access).
Convert UNIX permissions flags to a string
method Put(local As %String, remote As %String, remotemode As %String = "0600", append As %Boolean = 0) as %Status
Put a file from the local filesystem to the remote server, setting the specified mode (access).
method PutStream(stream As %Stream.Object, remote As %String, remotemode As %String = "0600", append As %Boolean = 0) as %Status
Put a stream to the remote system, setting the specified mode (access).
If stream is a file stream we will just link to the file already present, otherwise we create a temp file to send.
Rename a file on the remote server
Remove a directory on the remote server
Sets the transfer buffer size for SFTP operations (in bytes). The default is 1MB, performance may be
degraded when this is set to small values.
method SetFileTime(remote As %String, atimeUTC As %TimeStamp, mtimeUTC As %TimeStamp) as %Status
Change the access and last modification times for the specified file (you must be the current owner or root). NOTE: Timestamp values must be in UTC time (see $ZTIMESTAMP).
Change the uid/gid for the specified file or directory (you must be the current owner or root).
Change the permissions mode for the specified file or directory.
Change the size of the specified file (by either truncating or extending it).
Create a symlink on the remote server
classmethod Test(host As %String, username As %String, password As %String, dir As %String = "/etc", spec As %String = "", dotFiles As %Boolean = 1, ByRef t) as %Status
Demonstrates use of an SFTP session to enumerate the contents of the /etc directory on the remote
server.
classmethod TestPut(host As %String, username As %String, password As %String, srcfile As %String, destfile As %String) as %Status
Demonstrates use of an SFTP session to put a file to the remote
server.
Touch the file to have an access time of now.
Convert UNIX file time to $HOROLOG, for UNIX time is the number of seconds since Midnight Jan 1, 1970
which has a $HOROLOG date of 47117,0
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()