public class Scp extends Object
Constructor and Description |
---|
Scp() |
Scp(String user,
String host,
boolean withCipher,
String keyFile)
Establish a connection to a host with a given user name.
|
Modifier and Type | Method and Description |
---|---|
void |
copyFrom(File src,
File dest)
Copy a file from a remote source to a local destination.
|
void |
copyFrom(File src,
String dest)
Copy a file from a remote source to a local destination.
|
void |
copyFrom(String src,
File dest)
Copy a file from a remote source to a local destination.
|
void |
copyFrom(String src,
String dest)
Copy a file from a remote source to a local destination.
|
void |
copyTo(File src,
File dest)
Copy a file from a local source to a remote destination.
|
void |
copyTo(File src,
String dest)
Copy a file from a local source to a remote destination.
|
void |
copyTo(String src,
File dest)
Copy a file from a local source to a remote destination.
|
void |
copyTo(String src,
String dest)
Copy a file from a local source to a remote destination.
|
void |
disconnect()
Disconnect the session.
|
static String |
getHost(String ref)
Retrieve the host information from a SSH style connection string.
|
String |
getLastMessage()
Get the error message from the last error encountered.
|
static String |
getPath(String ref)
Retrieve the path information from a SSH style connection string.
|
static String |
getUser(String ref)
Retrieve the user information from a SSH style connection string.
|
boolean |
getVerbose()
Get the current verbose setting.
|
static void |
main(String[] args)
Command-line interface.
|
void |
mkdir(String path)
Create a folder on the remote system with the given path.
|
com.jcraft.jsch.Session |
openSession(String user,
String host,
boolean withCipher,
String keyFile)
Establish a connection to a host with a given user name.
|
void |
remove(String path)
Remove a file on the remote system with the given path.
|
void |
setVerbose(boolean verbose)
Set the verbose setting.
|
void |
showHelp()
Show the help for the tool.
|
public Scp()
public Scp(String user, String host, boolean withCipher, String keyFile) throws com.jcraft.jsch.JSchException, Exception
user
- the name of the user for establishing the connection.host
- the name of the host to connect to.withCipher
- a flag to indicate if encryption should stay in affect after establishing the connection.keyfile
- the name of the file contain the SSH key. Used only with the scp protocolcom.jcraft.jsch.JSchException
- if unable to connect to remote host using SSH protocol.Exception
- if any other error occurs.public static void main(String[] args)
args
- command-line arguments.public void showHelp()
public static String getUser(String ref)
ref
- the connection string.public static String getHost(String ref)
ref
- the connection string.public static String getPath(String ref)
ref
- the connection string.public com.jcraft.jsch.Session openSession(String user, String host, boolean withCipher, String keyFile) throws com.jcraft.jsch.JSchException, Exception
user
- the name of the user for establishing the connection.host
- the name of the host to connect to.withCipher
- a flag to indicate if encryption should stay in affect after establishing the connection.keyfile
- the name of the file contain the SSH key. Used only with the scp protocolcom.jcraft.jsch.JSchException
- if unable to connect to remote host using SSH protocol.Exception
- if any other error occurs.public void disconnect()
public void mkdir(String path) throws com.jcraft.jsch.JSchException, IOException
path
- the path to the desired folder.com.jcraft.jsch.JSchException
IOException
public void remove(String path) throws com.jcraft.jsch.JSchException, IOException
path
- the path to the desired file or folder.com.jcraft.jsch.JSchException
IOException
public void copyTo(File src, String dest) throws IOException, com.jcraft.jsch.JSchException
src
- the File
set the desired local source.dest
- the path on the remote host for the destination file.IOException
- if any errors occur.com.jcraft.jsch.JSchException
public void copyTo(String src, File dest) throws IOException, com.jcraft.jsch.JSchException
src
- the path to the local source.dest
- the File
set to the desired path on the remote host for the destination file.IOException
- if any errors occur.com.jcraft.jsch.JSchException
public void copyTo(File src, File dest) throws IOException, com.jcraft.jsch.JSchException
src
- the File
set the desired local source.dest
- the File
set to the desired path on the remote host for the destination file.IOException
- if any errors occur.com.jcraft.jsch.JSchException
public void copyTo(String src, String dest) throws IOException, com.jcraft.jsch.JSchException
src
- the File
set the desired local source.dest
- the path on the remote host for the destination file.com.jcraft.jsch.JSchException
IOException
- if any errors occur.public void copyFrom(File src, String dest) throws IOException
src
- the File
set to the desired source on the remote location.dest
- the path on the local host for the destination file.IOException
- if any errors occur.public void copyFrom(String src, File dest) throws IOException
src
- the path to the source file on the remote location.dest
- the File
set to the desired path on the local host for the destination file.IOException
- if any errors occur.public void copyFrom(File src, File dest) throws IOException
src
- the File
set to the desired source on the remote location.dest
- the File
set to the desired path on the local host for the destination file.IOException
- if any errors occur.public void copyFrom(String src, String dest) throws IOException
src
- the path to the source file on the remote location.dest
- the path on the local host for the destination file.IOException
- if any errors occur.public String getLastMessage()
public boolean getVerbose()
public void setVerbose(boolean verbose)
verbose
- the desired setting. True for on, False for offCopyright © 2014-2016 Regents University of California. All Rights Reserved.