Package com.sshtools.client.scp
Class ScpClient
java.lang.Object
com.sshtools.client.scp.ScpClientIO
com.sshtools.client.scp.ScpClient
Implements an SCP (Secure Copy) client which may be useful for SSH1
connections and SSH2 where SFTP is not available.
- Author:
- Lee David Painter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classImplements an SCP Engine by extending J2SSH Mavericjs ScpEngineIONested classes/interfaces inherited from class com.sshtools.client.scp.ScpClientIO
ScpClientIO.ScpEngineIO -
Field Summary
Fields inherited from class com.sshtools.client.scp.ScpClientIO
ssh -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexit()voidDownloads an array of remote files to the local computer.voidget(String localFile, String[] remoteFiles, boolean recursive, FileTransferProgress progress) voidDownloads a remote file onto the local computer.voidget(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress) voidUploads an array of local files onto the remote server.voidput(String[] localFiles, String remoteFile, boolean recursive, FileTransferProgress progress) Uploads an array of local files onto the remote server.voidUploads a local file onto the remote server.voidput(String localFileRegExp, String remoteFile, boolean recursive, FileTransferProgress progress) pattern matches the files in the local directory using "local" as a glob Regular Expression.voidput(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) voidputFile(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) Deprecated.Use put method instead.voidsetPacketSize(int packetSize) voidsetWindowSpace(int windowSpace)
-
Constructor Details
-
ScpClient
Creates an SCP client. CWD (Current working directory) will be the users home directory.
- Parameters:
ssh- A connected SshClient- Throws:
IOExceptionPermissionDeniedException
-
ScpClient
- Parameters:
cwd-ssh-- Throws:
PermissionDeniedExceptionIOException
-
ScpClient
public ScpClient(AbstractFileFactory<?> fileFactory, SshClient ssh) throws PermissionDeniedException, IOException Creates an SCP client.
- Parameters:
cwd- The current local directoryssh- A connected SshClient- Throws:
IOExceptionPermissionDeniedException
-
-
Method Details
-
setWindowSpace
public void setWindowSpace(int windowSpace) -
setPacketSize
public void setPacketSize(int packetSize) -
put
public void put(String localFile, String remoteFile, boolean recursive) throws SshException, ChannelOpenException, SftpStatusException, IOException, PermissionDeniedException Uploads a local file onto the remote server.
Treats localFile as a glob regular expression, and puts the files that match into the remote directory.
Code examples can be found in ScpConnect.java
Code Example
//put all .doc files with 'rfc' in their names, in the 'docs/unsorted/' folder relative to the local cwd, and copy them to remoteFile. If remoteFile is a filename then the remote file will have this name unless multiple local files are matched in which case an exception will be thrown. scp.put("docs/unsorted/*rfc*.doc");- Parameters:
localFile- The path to the local file relative to the local current directory; may be a file or directoryremoteFile- The path on the remote server, may be a file or directoryrecursive- Copy the contents of a directory recursivly- Throws:
SshException- if an IO error occurs during the operationSftpStatusExceptionPermissionDeniedExceptionIOExceptionChannelOpenException
-
putFile
public void putFile(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) throws SshException, ChannelOpenException, IOException, PermissionDeniedException Deprecated.Use put method instead.- Parameters:
localFile-remoteFile-recursive-progress-remoteIsDir- if called by put(string[]...) then remoteFile must be a directory so need -d option.- Throws:
SshExceptionChannelOpenExceptionPermissionDeniedExceptionIOException
-
put
public void put(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) throws SshException, ChannelOpenException, IOException, PermissionDeniedException - Parameters:
localFile-remoteFile-recursive-progress-remoteIsDir- if called by put(string[]...) then remoteFile must be a directory so need -d option.- Throws:
SshExceptionChannelOpenExceptionPermissionDeniedExceptionIOException
-
put
public void put(String localFileRegExp, String remoteFile, boolean recursive, FileTransferProgress progress) throws SshException, ChannelOpenException, SftpStatusException, IOException, PermissionDeniedException pattern matches the files in the local directory using "local" as a glob Regular Expression. For the matching file array put is called to copy the file to the remote directory.- Parameters:
localFileRegExp-remoteFile-recursive-progress-- Throws:
SshExceptionChannelOpenExceptionPermissionDeniedExceptionIOExceptionSftpStatusException
-
put
public void put(String[] localFiles, String remoteFile, boolean recursive) throws SshException, ChannelOpenException, IOException, PermissionDeniedException Uploads an array of local files onto the remote server.
- Parameters:
localFiles- an array of local files; may be files or directoriesremoteFile- the path on the remote server, may be a file or directory.recursive- Copy the contents of directorys recursivly- Throws:
PermissionDeniedExceptionIOException- if an IO error occurs during the operationSshExceptionChannelOpenException
-
put
public void put(String[] localFiles, String remoteFile, boolean recursive, FileTransferProgress progress) throws SshException, ChannelOpenException, IOException, PermissionDeniedException Uploads an array of local files onto the remote server.
- Parameters:
localFiles- an array of local files; may be files or directoriesremoteFile- the path on the remote server, may be a file or directory1recursive- Copy the contents of directorys recursivly- Throws:
PermissionDeniedExceptionIOException- if an IO error occurs during the operationSshExceptionChannelOpenException
-
get
public void get(String localDir, String[] remoteFiles, boolean recursive) throws SshException, ChannelOpenException, IOException, PermissionDeniedException Downloads an array of remote files to the local computer.
- Parameters:
localDir- The local path to place the filesremoteFiles- The path of the remote filesrecursive- recursively copy the contents of a directory- Throws:
PermissionDeniedExceptionIOException- if an IO error occurs during the operationSshExceptionChannelOpenException
-
get
public void get(String localFile, String[] remoteFiles, boolean recursive, FileTransferProgress progress) throws SshException, ChannelOpenException, IOException, PermissionDeniedException -
get
public void get(String localFile, String remoteFile, boolean recursive) throws SshException, ChannelOpenException, IOException, PermissionDeniedException Downloads a remote file onto the local computer.
- Parameters:
localFile- The path to place the fileremoteFile- The path of the file on the remote serverrecursive- recursivly copy the contents of a directory- Throws:
PermissionDeniedExceptionIOException- if an IO error occurs during the operationSshExceptionChannelOpenException
-
get
public void get(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress) throws SshException, ChannelOpenException, IOException, PermissionDeniedException -
exit
- Throws:
SshExceptionIOException
-