public class SftpExec extends SshExec
SshExec and uses its method to execute a
sftp command in batch mode to transfer files between two remote machines
SshExecjschSession, session| Constructor and Description |
|---|
SftpExec(java.lang.String user,
java.lang.String host)
Creates session with give user and host name and default port
|
SftpExec(java.lang.String user,
java.lang.String host,
int port)
Creates a session with given user name, host and port
|
| Modifier and Type | Method and Description |
|---|---|
int |
copyFrom(java.lang.String rfile,
java.io.File localPath,
boolean recursive)
Copies file/directory from a remote machine to local machine using Jsch
sftp channel.
|
int |
copyTo(java.io.File lfile,
java.lang.String targetPath,
boolean recursive)
Copies files/directories from local machine to remote host
|
java.lang.String |
getRecursiveCopyCmd(java.lang.String srcFile,
java.lang.String destFile,
boolean isConnectionOrigin)
Returns the list of sftp commands (combination of "mkdir" and "put"
commands) that are required to recursively copy a directory.
|
java.util.Vector<java.lang.String> |
getWildcardFileListing(java.lang.String remoteFile,
java.lang.String seperator)
Anand: Receives the remote wildcard and returns list of files matching the pattern
|
boolean |
isRegularOrLinkFile(java.lang.String srcFile)
Checks if a given file is a regular file.
|
_copyTo, addIdentity, addIdentity, addPortForwardL, addPortForwardR, checkAck, closeConnection, executeCmd, executeCmd, getForcedCleanUp, getTimeout, getwildcardFileListingBBCP, isRemoteFileDirectory, openConnection, removePortForwardL, removePortForwardR, setcmdLineOptions, setForcedCleanUp, setPortForwardingL, setPortForwardingR, setProtocolPath, setPseudoTerminal, setTimeout, setTimeoutcopyFrom, copyTo, createDir, deleteFile, killpublic SftpExec(java.lang.String user, java.lang.String host)
user - host - public SftpExec(java.lang.String user, java.lang.String host, int port)
user - host - port - public int copyFrom(java.lang.String rfile, java.io.File localPath, boolean recursive) throws SshException
copyFrom in interface ExecInterfacecopyFrom in class SshExecrfile - - remote file that should be copied to local machinelocalPath - - path into to which the source file should be copiedrecursive - - flag to represent recursive copy of a directorySshExceptionpublic java.util.Vector<java.lang.String> getWildcardFileListing(java.lang.String remoteFile, java.lang.String seperator) throws java.lang.Exception
remoteFile - : Wildcard pattern with pathseperator - : OS path seperatorjava.lang.Exceptionpublic int copyTo(java.io.File lfile, java.lang.String targetPath, boolean recursive) throws SshException
copyTo in interface ExecInterfacecopyTo in class RemoteExeclfile - - local file that should be copied to remote machinetargetPath - - path on remote host into to which the file should be copiedrecursive - - flag to represent recursive copy of a directorySshExceptionpublic java.lang.String getRecursiveCopyCmd(java.lang.String srcFile, java.lang.String destFile, boolean isConnectionOrigin) throws SshException
srcFile - - source file to be copieddestFile - - destination directoryisConnectionOrigin - SshExceptionpublic boolean isRegularOrLinkFile(java.lang.String srcFile) throws SshException, com.jcraft.jsch.JSchException
srcFile - - file that is to be checked for its typeSshExceptioncom.jcraft.jsch.JSchException