|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectexamples.SCPExample2
Copy a file to/from an SSH1 or SSH2 server using the scp protocol. The scp protocol was introduced with ssh1 and is very similar to the rcp protocol.
See the main
method for an example on how to do a file
transfer, and also how to expand glob expressions.
The copyFilesWithSSH1
method will copy files using the SSH1 protocol.
The copyFilesWithSSH2
method will copy files using the SSH2 protocol.
The doGlob
method will expand glob expressions.
This example requires Java 1.4.
SSHSCP1
,
SFTPCopyFile
Constructor Summary | |
SCPExample2()
|
Method Summary | |
static void |
copyFilesWithSSH1(java.lang.String server,
int port,
java.lang.String user,
java.lang.String privatekeyfile,
java.lang.String privatekeypassword,
java.lang.String[] files,
java.lang.String destination,
boolean toremote)
This copies files using an SSH1 connection. |
static void |
copyFilesWithSSH2(java.lang.String server,
int port,
java.lang.String user,
java.lang.String privatekeyfile,
java.lang.String privatekeypassword,
java.lang.String[] files,
java.lang.String destination,
boolean toremote)
This copies files using an SSH2 connection. |
static void |
main(java.lang.String[] argv)
Run the application |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SCPExample2()
Method Detail |
public static void copyFilesWithSSH1(java.lang.String server, int port, java.lang.String user, java.lang.String privatekeyfile, java.lang.String privatekeypassword, java.lang.String[] files, java.lang.String destination, boolean toremote) throws java.io.IOException, java.net.UnknownHostException
server
- server nameport
- server portuser
- user nameprivatekeyfile
- the private key file, if null we will try to find the OpenSSH private key fileprivatekeypassword
- the password for the private key file, null if none neededfiles
- an array of files that should be transferreddestination
- the destination file or directorytoremote
- true if files should be copied to the remote server, otherwise false
java.io.IOException
java.net.UnknownHostException
public static void copyFilesWithSSH2(java.lang.String server, int port, java.lang.String user, java.lang.String privatekeyfile, java.lang.String privatekeypassword, java.lang.String[] files, java.lang.String destination, boolean toremote) throws java.io.IOException, java.net.UnknownHostException, SSH2Exception
server
- server nameport
- server portuser
- user nameprivatekeyfile
- the private key file, if null we will try to find the OpenSSH private key fileprivatekeypassword
- the password for the private key file, null if none neededfiles
- an array of files that should be transferreddestination
- the destination file or directorytoremote
- true if files should be copied to the remote server, otherwise false
java.io.IOException
java.net.UnknownHostException
SSH2Exception
public static void main(java.lang.String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |