Package com.jcraft.jsch
Class ChannelSftp
- java.lang.Object
-
- com.jcraft.jsch.Channel
-
- com.jcraft.jsch.ChannelSftp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ChannelSftp.LsEntry
static interface
ChannelSftp.LsEntrySelector
This interface will be passed as an argument forls
method.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
agent_forwarding
static int
APPEND
protected Hashtable
env
static int
OVERWRITE
protected boolean
pty
static int
RESUME
static int
SSH_FX_BAD_MESSAGE
static int
SSH_FX_CONNECTION_LOST
static int
SSH_FX_EOF
static int
SSH_FX_FAILURE
static int
SSH_FX_NO_CONNECTION
static int
SSH_FX_NO_SUCH_FILE
static int
SSH_FX_OK
static int
SSH_FX_OP_UNSUPPORTED
static int
SSH_FX_PERMISSION_DENIED
protected int
tcol
protected byte[]
terminal_mode
protected int
thp
protected int
trow
protected String
ttype
protected int
twp
protected boolean
xforwading
-
Constructor Summary
Constructors Constructor Description ChannelSftp()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
_put(InputStream src, String dst, SftpProgressMonitor monitor, int mode)
void
cd(String path)
void
chgrp(int gid, String path)
void
chmod(int permissions, String path)
void
chown(int uid, String path)
void
disconnect()
void
exit()
InputStream
get(String src)
InputStream
get(String src, int mode)
Deprecated.This method will be deleted in the future.InputStream
get(String src, SftpProgressMonitor monitor)
InputStream
get(String src, SftpProgressMonitor monitor, int mode)
Deprecated.This method will be deleted in the future.InputStream
get(String src, SftpProgressMonitor monitor, long skip)
void
get(String src, OutputStream dst)
void
get(String src, OutputStream dst, SftpProgressMonitor monitor)
void
get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip)
void
get(String src, String dst)
void
get(String src, String dst, SftpProgressMonitor monitor)
void
get(String src, String dst, SftpProgressMonitor monitor, int mode)
int
getBulkRequests()
This method will return the value how many requests may be sent at any one time.String
getExtension(String key)
String
getHome()
int
getServerVersion()
void
hardlink(String oldpath, String newpath)
void
lcd(String path)
String
lpwd()
Vector
ls(String path)
void
ls(String path, ChannelSftp.LsEntrySelector selector)
List files specified by the remotepath
.SftpATTRS
lstat(String path)
void
mkdir(String path)
void
put(InputStream src, String dst)
void
put(InputStream src, String dst, int mode)
void
put(InputStream src, String dst, SftpProgressMonitor monitor)
void
put(InputStream src, String dst, SftpProgressMonitor monitor, int mode)
Sends data from the input streamsrc
todst
file.OutputStream
put(String dst)
OutputStream
put(String dst, int mode)
OutputStream
put(String dst, SftpProgressMonitor monitor, int mode)
OutputStream
put(String dst, SftpProgressMonitor monitor, int mode, long offset)
Sends data from the output stream todst
file.void
put(String src, String dst)
void
put(String src, String dst, int mode)
void
put(String src, String dst, SftpProgressMonitor monitor)
void
put(String src, String dst, SftpProgressMonitor monitor, int mode)
Sends data fromsrc
file todst
file.String
pwd()
void
quit()
String
readlink(String path)
String
realpath(String path)
void
rename(String oldpath, String newpath)
void
rm(String path)
void
rmdir(String path)
void
run()
protected void
sendRequests()
void
setAgentForwarding(boolean enable)
Enable the agent forwarding.void
setBulkRequests(int bulk_requests)
Specify how many requests may be sent at any one time.void
setEnv(byte[] name, byte[] value)
Set the environment variable.void
setEnv(String name, String value)
Set the environment variable.void
setEnv(Hashtable env)
Deprecated.UsesetEnv(String, String)
orsetEnv(byte[], byte[])
instead.void
setFilenameEncoding(String encoding)
void
setMtime(String path, int mtime)
void
setPty(boolean enable)
Allocate a Pseudo-Terminal.void
setPtySize(int col, int row, int wp, int hp)
Change the window dimension interactively.void
setPtyType(String ttype)
Set the terminal type.void
setPtyType(String ttype, int col, int row, int wp, int hp)
Set the terminal type.void
setStat(String path, SftpATTRS attr)
void
setTerminalMode(byte[] terminal_mode)
Set the terminal mode.void
setXForwarding(boolean enable)
Enable the X11 forwarding.void
start()
SftpATTRS
stat(String path)
SftpStatVFS
statVFS(String path)
void
symlink(String oldpath, String newpath)
String
version()
-
Methods inherited from class com.jcraft.jsch.Channel
connect, connect, genChannelOpenPacket, getExitStatus, getExtInputStream, getId, getInputStream, getOutputStream, getSession, isClosed, isConnected, isEOF, sendChannelOpen, sendOpenConfirmation, sendOpenFailure, sendSignal, setExtOutputStream, setExtOutputStream, setInputStream, setInputStream, setOutputStream, setOutputStream
-
-
-
-
Field Detail
-
SSH_FX_OK
public static final int SSH_FX_OK
- See Also:
- Constant Field Values
-
SSH_FX_EOF
public static final int SSH_FX_EOF
- See Also:
- Constant Field Values
-
SSH_FX_NO_SUCH_FILE
public static final int SSH_FX_NO_SUCH_FILE
- See Also:
- Constant Field Values
-
SSH_FX_PERMISSION_DENIED
public static final int SSH_FX_PERMISSION_DENIED
- See Also:
- Constant Field Values
-
SSH_FX_FAILURE
public static final int SSH_FX_FAILURE
- See Also:
- Constant Field Values
-
SSH_FX_BAD_MESSAGE
public static final int SSH_FX_BAD_MESSAGE
- See Also:
- Constant Field Values
-
SSH_FX_NO_CONNECTION
public static final int SSH_FX_NO_CONNECTION
- See Also:
- Constant Field Values
-
SSH_FX_CONNECTION_LOST
public static final int SSH_FX_CONNECTION_LOST
- See Also:
- Constant Field Values
-
SSH_FX_OP_UNSUPPORTED
public static final int SSH_FX_OP_UNSUPPORTED
- See Also:
- Constant Field Values
-
OVERWRITE
public static final int OVERWRITE
- See Also:
- Constant Field Values
-
RESUME
public static final int RESUME
- See Also:
- Constant Field Values
-
APPEND
public static final int APPEND
- See Also:
- Constant Field Values
-
agent_forwarding
protected boolean agent_forwarding
-
xforwading
protected boolean xforwading
-
env
protected Hashtable env
-
pty
protected boolean pty
-
ttype
protected String ttype
-
tcol
protected int tcol
-
trow
protected int trow
-
twp
protected int twp
-
thp
protected int thp
-
terminal_mode
protected byte[] terminal_mode
-
-
Method Detail
-
setBulkRequests
public void setBulkRequests(int bulk_requests) throws JSchException
Specify how many requests may be sent at any one time. Increasing this value may slightly improve file transfer speed but will increase memory usage. The default is 16 requests.- Parameters:
bulk_requests
- how many requests may be outstanding at any one time.- Throws:
JSchException
-
getBulkRequests
public int getBulkRequests()
This method will return the value how many requests may be sent at any one time.- Returns:
- how many requests may be sent at any one time.
-
start
public void start() throws JSchException
- Overrides:
start
in classChannel
- Throws:
JSchException
-
quit
public void quit()
-
exit
public void exit()
-
lcd
public void lcd(String path) throws SftpException
- Throws:
SftpException
-
cd
public void cd(String path) throws SftpException
- Throws:
SftpException
-
put
public void put(String src, String dst) throws SftpException
- Throws:
SftpException
-
put
public void put(String src, String dst, int mode) throws SftpException
- Throws:
SftpException
-
put
public void put(String src, String dst, SftpProgressMonitor monitor) throws SftpException
- Throws:
SftpException
-
put
public void put(String src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException
Sends data fromsrc
file todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- Parameters:
src
- source filedst
- destination filemonitor
- progress monitormode
- how data should be added to dst- Throws:
SftpException
-
put
public void put(InputStream src, String dst) throws SftpException
- Throws:
SftpException
-
put
public void put(InputStream src, String dst, int mode) throws SftpException
- Throws:
SftpException
-
put
public void put(InputStream src, String dst, SftpProgressMonitor monitor) throws SftpException
- Throws:
SftpException
-
put
public void put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException
Sends data from the input streamsrc
todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- Parameters:
src
- input streamdst
- destination filemonitor
- progress monitormode
- how data should be added to dst- Throws:
SftpException
-
_put
public void _put(InputStream src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException
- Throws:
SftpException
-
put
public OutputStream put(String dst) throws SftpException
- Throws:
SftpException
-
put
public OutputStream put(String dst, int mode) throws SftpException
- Throws:
SftpException
-
put
public OutputStream put(String dst, SftpProgressMonitor monitor, int mode) throws SftpException
- Throws:
SftpException
-
put
public OutputStream put(String dst, SftpProgressMonitor monitor, int mode, long offset) throws SftpException
Sends data from the output stream todst
file. Themode
should beOVERWRITE
,RESUME
orAPPEND
.- Parameters:
dst
- destination filemonitor
- progress monitormode
- how data should be added to dstoffset
- data will be added at offset- Returns:
- output stream, which accepts data to be transferred.
- Throws:
SftpException
-
get
public void get(String src, String dst) throws SftpException
- Throws:
SftpException
-
get
public void get(String src, String dst, SftpProgressMonitor monitor) throws SftpException
- Throws:
SftpException
-
get
public void get(String src, String dst, SftpProgressMonitor monitor, int mode) throws SftpException
- Throws:
SftpException
-
get
public void get(String src, OutputStream dst) throws SftpException
- Throws:
SftpException
-
get
public void get(String src, OutputStream dst, SftpProgressMonitor monitor) throws SftpException
- Throws:
SftpException
-
get
public void get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip) throws SftpException
- Throws:
SftpException
-
get
public InputStream get(String src) throws SftpException
- Throws:
SftpException
-
get
public InputStream get(String src, SftpProgressMonitor monitor) throws SftpException
- Throws:
SftpException
-
get
public InputStream get(String src, int mode) throws SftpException
Deprecated.This method will be deleted in the future.- Throws:
SftpException
-
get
public InputStream get(String src, SftpProgressMonitor monitor, int mode) throws SftpException
Deprecated.This method will be deleted in the future.- Throws:
SftpException
-
get
public InputStream get(String src, SftpProgressMonitor monitor, long skip) throws SftpException
- Throws:
SftpException
-
ls
public Vector ls(String path) throws SftpException
- Throws:
SftpException
-
ls
public void ls(String path, ChannelSftp.LsEntrySelector selector) throws SftpException
List files specified by the remotepath
. Each files and directories will be passed toLsEntrySelector#select(LsEntry)
method, and if that method returnsLsEntrySelector#BREAK
, the operation will be canceled immediately.- Throws:
SftpException
- Since:
- 0.1.47
- See Also:
ChannelSftp.LsEntrySelector
-
readlink
public String readlink(String path) throws SftpException
- Throws:
SftpException
-
symlink
public void symlink(String oldpath, String newpath) throws SftpException
- Throws:
SftpException
-
hardlink
public void hardlink(String oldpath, String newpath) throws SftpException
- Throws:
SftpException
-
rename
public void rename(String oldpath, String newpath) throws SftpException
- Throws:
SftpException
-
rm
public void rm(String path) throws SftpException
- Throws:
SftpException
-
chgrp
public void chgrp(int gid, String path) throws SftpException
- Throws:
SftpException
-
chown
public void chown(int uid, String path) throws SftpException
- Throws:
SftpException
-
chmod
public void chmod(int permissions, String path) throws SftpException
- Throws:
SftpException
-
setMtime
public void setMtime(String path, int mtime) throws SftpException
- Throws:
SftpException
-
rmdir
public void rmdir(String path) throws SftpException
- Throws:
SftpException
-
mkdir
public void mkdir(String path) throws SftpException
- Throws:
SftpException
-
stat
public SftpATTRS stat(String path) throws SftpException
- Throws:
SftpException
-
statVFS
public SftpStatVFS statVFS(String path) throws SftpException
- Throws:
SftpException
-
lstat
public SftpATTRS lstat(String path) throws SftpException
- Throws:
SftpException
-
setStat
public void setStat(String path, SftpATTRS attr) throws SftpException
- Throws:
SftpException
-
pwd
public String pwd() throws SftpException
- Throws:
SftpException
-
lpwd
public String lpwd()
-
version
public String version()
-
getHome
public String getHome() throws SftpException
- Throws:
SftpException
-
disconnect
public void disconnect()
- Overrides:
disconnect
in classChannel
-
getServerVersion
public int getServerVersion() throws SftpException
- Throws:
SftpException
-
setFilenameEncoding
public void setFilenameEncoding(String encoding) throws SftpException
- Throws:
SftpException
-
realpath
public String realpath(String path) throws SftpException
- Throws:
SftpException
-
setAgentForwarding
public void setAgentForwarding(boolean enable)
Enable the agent forwarding.- Parameters:
enable
-
-
setXForwarding
public void setXForwarding(boolean enable)
Enable the X11 forwarding. Refer to RFC4254 6.3.1. Requesting X11 Forwarding.- Overrides:
setXForwarding
in classChannel
- Parameters:
enable
-
-
setEnv
public void setEnv(Hashtable env)
Deprecated.UsesetEnv(String, String)
orsetEnv(byte[], byte[])
instead.- See Also:
setEnv(String, String)
,setEnv(byte[], byte[])
-
setEnv
public void setEnv(String name, String value)
Set the environment variable. Ifname
andvalue
are needed to be passed to the remote in your favorite encoding, usesetEnv(byte[], byte[])
. Refer to RFC4254 6.4 Environment Variable Passing.- Parameters:
name
- A name for environment variable.value
- A value for environment variable.
-
setEnv
public void setEnv(byte[] name, byte[] value)
Set the environment variable. Refer to RFC4254 6.4 Environment Variable Passing.- Parameters:
name
- A name of environment variable.value
- A value of environment variable.- See Also:
setEnv(String, String)
-
setPty
public void setPty(boolean enable)
Allocate a Pseudo-Terminal. Refer to RFC4254 6.2. Requesting a Pseudo-Terminal.- Parameters:
enable
-
-
setTerminalMode
public void setTerminalMode(byte[] terminal_mode)
Set the terminal mode.- Parameters:
terminal_mode
-
-
setPtySize
public void setPtySize(int col, int row, int wp, int hp)
Change the window dimension interactively. Refer to RFC4254 6.7. Window Dimension Change Message.- Parameters:
col
- terminal width, columnsrow
- terminal height, rowswp
- terminal width, pixelshp
- terminal height, pixels
-
setPtyType
public void setPtyType(String ttype)
Set the terminal type. This method is not effective after Channel#connect().- Parameters:
ttype
- terminal type(for example, "vt100")- See Also:
setPtyType(String, int, int, int, int)
-
setPtyType
public void setPtyType(String ttype, int col, int row, int wp, int hp)
Set the terminal type. This method is not effective after Channel#connect().- Parameters:
ttype
- terminal type(for example, "vt100")col
- terminal width, columnsrow
- terminal height, rowswp
- terminal width, pixelshp
- terminal height, pixels
-
-