Class Scp


  • public class Scp
    extends Object
    Class for SCP actions.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • Scp

        public Scp()
    • Method Detail

      • copyTo

        public static String copyTo​(LoggingObject owner,
                                    SSHSessionProvider provider,
                                    File localFile,
                                    String remoteFile)
        Copies a local file to a remote server.
        Parameters:
        owner - the owner that initiates the transfer, can be null
        provider - the SSH session provider to use
        localFile - the local file
        remoteFile - the remote file
        Returns:
        null if successful, otherwise error message
      • copyTo

        public static String copyTo​(LoggingObject owner,
                                    SSHSessionProvider provider,
                                    String host,
                                    int port,
                                    File localFile,
                                    String remoteFile)
        Copies a local file to a remote server.
        Parameters:
        owner - the owner that initiates the transfer, can be null
        provider - the SSH session provider to use
        host - an alternative host, null if to use one from connection
        port - an alternative port, ignored if host null
        localFile - the local file
        remoteFile - the remote file
        Returns:
        null if successful, otherwise error message
      • copyFrom

        public static String copyFrom​(LoggingObject owner,
                                      SSHSessionProvider provider,
                                      String remoteFile,
                                      File localFile)
        Copies a remote file onto the local machine.
        Parameters:
        owner - the owner that initiates the transfer
        provider - the SSH session provider to use
        remoteFile - the remote file to copy
        localFile - the local file
        Returns:
        null if successful, otherwise error message
      • copyFrom

        public static String copyFrom​(LoggingObject owner,
                                      SSHSessionProvider provider,
                                      String host,
                                      int port,
                                      String remoteFile,
                                      File localFile)
        Copies a remote file onto the local machine.
        Parameters:
        owner - the owner that initiates the transfer
        provider - the SSH session provider to use
        host - an alternative host, null if to use one from connection
        port - an alternative port, ignored if host null
        remoteFile - the remote file to copy
        localFile - the local file
        Returns:
        null if successful, otherwise error message
      • checkAck

        public static int checkAck​(InputStream in)
                            throws IOException
        Checks the stream (scp).
        Parameters:
        in - the stream to use
        Returns:
        0 = success, 1 = error, 2 = fatal error, -1 = end of stream
        Throws:
        IOException