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 class
Implements 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 TypeMethodDescriptionvoid
exit()
void
Downloads an array of remote files to the local computer.void
get
(String localFile, String[] remoteFiles, boolean recursive, FileTransferProgress progress) void
Downloads a remote file onto the local computer.void
get
(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress) void
Uploads an array of local files onto the remote server.void
put
(String[] localFiles, String remoteFile, boolean recursive, FileTransferProgress progress) Uploads an array of local files onto the remote server.void
Uploads a local file onto the remote server.void
put
(String localFileRegExp, String remoteFile, boolean recursive, FileTransferProgress progress) pattern matches the files in the local directory using "local" as a glob Regular Expression.void
put
(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) void
putFile
(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) Deprecated.Use put method instead.void
setPacketSize
(int packetSize) void
setWindowSpace
(int windowSpace)
-
Constructor Details
-
ScpClient
public ScpClient(SshClient ssh) throws com.sshtools.common.permissions.PermissionDeniedException, IOException Creates an SCP client. CWD (Current working directory) will be the users home directory.
- Parameters:
ssh
- A connected SshClient- Throws:
IOException
com.sshtools.common.permissions.PermissionDeniedException
-
ScpClient
public ScpClient(File cwd, SshClient ssh) throws com.sshtools.common.permissions.PermissionDeniedException, IOException - Parameters:
cwd
-ssh
-- Throws:
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
ScpClient
public ScpClient(com.sshtools.common.files.AbstractFileFactory<?> fileFactory, SshClient ssh) throws com.sshtools.common.permissions.PermissionDeniedException, IOException Creates an SCP client.
- Parameters:
cwd
- The current local directoryssh
- A connected SshClient- Throws:
IOException
com.sshtools.common.permissions.PermissionDeniedException
-
-
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 com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, com.sshtools.common.sftp.SftpStatusException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.ssh.SshException
- if an IO error occurs during the operationcom.sshtools.common.sftp.SftpStatusException
com.sshtools.common.permissions.PermissionDeniedException
IOException
com.sshtools.common.ssh.ChannelOpenException
-
putFile
public void putFile(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress, boolean remoteIsDir) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.PermissionDeniedException - Parameters:
localFile
-remoteFile
-recursive
-progress
-remoteIsDir
- if called by put(string[]...) then remoteFile must be a directory so need -d option.- Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
com.sshtools.common.permissions.PermissionDeniedException
IOException
-
put
public void put(String localFileRegExp, String remoteFile, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, com.sshtools.common.sftp.SftpStatusException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
com.sshtools.common.permissions.PermissionDeniedException
IOException
com.sshtools.common.sftp.SftpStatusException
-
put
public void put(String[] localFiles, String remoteFile, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.permissions.PermissionDeniedException
IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
-
put
public void put(String[] localFiles, String remoteFile, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.permissions.PermissionDeniedException
IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
-
get
public void get(String localDir, String[] remoteFiles, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.permissions.PermissionDeniedException
IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
-
get
public void get(String localFile, String[] remoteFiles, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.PermissionDeniedException - Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
IOException
com.sshtools.common.permissions.PermissionDeniedException
-
get
public void get(String localFile, String remoteFile, boolean recursive) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.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:
com.sshtools.common.permissions.PermissionDeniedException
IOException
- if an IO error occurs during the operationcom.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
-
get
public void get(String localFile, String remoteFile, boolean recursive, FileTransferProgress progress) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.ChannelOpenException, IOException, com.sshtools.common.permissions.PermissionDeniedException - Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.ChannelOpenException
IOException
com.sshtools.common.permissions.PermissionDeniedException
-
exit
- Throws:
com.sshtools.common.ssh.SshException
IOException
-