public class ScpCopier extends FileCopierBase
Copy operation will overwrite existing files by default. Copy between a local host and a remote host ignores the variables forcedCleanup, and timeout.
When transferring files between local machine and a remote machine, if the remote machine does not have scp in standard path, you can set it using the variables protocolPathSrc/protocolPathDest.
When transferring files between two remote machines, the scp command is run from the source machine. Is scp is not in standard path on source machine, set the path in protocolPathSrc variable. If this variable is not set, class attempts to search in the most common locations - /usr/bin, /bin, /usr/local/bin, . , and ~
FileCopierBase.CopyResult
Modifier and Type | Field and Description |
---|---|
protected com.jcraft.jsch.Session |
jschSession |
protected SshSession |
session |
cmdLineOptions, forcedCleanup, protocolPathDest, protocolPathSrc, timeout
Constructor and Description |
---|
ScpCopier() |
Modifier and Type | Method and Description |
---|---|
java.lang.StringBuffer |
buildSCPRemoteDestinationCommand(java.lang.String fileName,
int destPort,
java.lang.String destFile,
boolean recursive) |
protected FileCopierBase.CopyResult |
copyFrom(ConnectionDetails srcDetails,
java.lang.String srcFile,
java.lang.String destFile,
boolean recursive)
Copies file from a remote host to local machine
|
protected FileCopierBase.CopyResult |
copyRemote(ConnectionDetails srcDetails,
java.lang.String srcFile,
ConnectionDetails destDetails,
java.lang.String destFile,
boolean recursive)
Copies files between two remote machines.
|
protected FileCopierBase.CopyResult |
copyTo(java.lang.String srcFile,
ConnectionDetails destDetails,
java.lang.String destFile,
boolean recursive)
Copies files from local machine to a remote host
|
protected int |
getDefaultPort()
default port for the file transfer protocol.
|
protected boolean |
isScpPresent(ConnectionDetails srcDetails,
ConnectionDetails destDetails) |
copy, copyLocal, copyLocalOnRemoteMachine, getCmdLineOptions, getCmdWithDefaultPath, getProtocolPathDest, getProtocolPathSrc, getTimeout, isForcedCleanup, setCleanup, setCmdLineOptions, setProtocolPathDest, setProtocolPathSrc, setTimeout
protected SshSession session
protected com.jcraft.jsch.Session jschSession
public ScpCopier()
protected FileCopierBase.CopyResult copyFrom(ConnectionDetails srcDetails, java.lang.String srcFile, java.lang.String destFile, boolean recursive)
FileCopierBase
copyFrom
in class FileCopierBase
srcDetails
- - object containing the source machine connection detailssrcFile
- - source file to be copieddestFile
- - local path into which source should be copiedrecursive
- - flag to indicate if directories should be copied recursivelyprotected FileCopierBase.CopyResult copyTo(java.lang.String srcFile, ConnectionDetails destDetails, java.lang.String destFile, boolean recursive) throws SshException
FileCopierBase
copyTo
in class FileCopierBase
srcFile
- - local source file to be copieddestDetails
- - object containing the destination machine connection detailsdestFile
- - path into which source should be copiedrecursive
- - flag to indicate if directories should be copied recursivelySshException
protected FileCopierBase.CopyResult copyRemote(ConnectionDetails srcDetails, java.lang.String srcFile, ConnectionDetails destDetails, java.lang.String destFile, boolean recursive) throws ExecException
FileCopierBase
copyRemote
in class FileCopierBase
srcDetails
- - object containing the source machine connection detailssrcFile
- - source file to be copieddestDetails
- - object containing the destination machine connection detailsdestFile
- - path into which source should be copiedrecursive
- - flag to indicate if directory should be copied recursivelyExecException
public java.lang.StringBuffer buildSCPRemoteDestinationCommand(java.lang.String fileName, int destPort, java.lang.String destFile, boolean recursive)
protected boolean isScpPresent(ConnectionDetails srcDetails, ConnectionDetails destDetails)
protected int getDefaultPort()
FileCopierBase
getDefaultPort
in class FileCopierBase