Establish a SFTP communication (Secure File Transfer Protocol).

1 sftp

<sftp
    host='host'
    port='port'
    user='user'
    password='password'
    debug='debug'
>
    <sftp.pwd /> *
    <sftp.list /> *
    <sftp.put /> *
    <sftp.get /> *
    <sftp.exists /> *
    <sftp.rename /> *
    <sftp.delete /> *
    <sftp.mkdir /> *
    <sftp.listFiles /> *
    <sftp.file.getName /> *
    <sftp.file.getSize /> *
    <sftp.file.isDirectory /> *
    <sftp.file.getTimestamp /> *
    <sftp.listFilesAsResultSet /> *
    <sftp.cwd /> *
    <sftp.getBytes /> *
</sftp>
Example

Before execute the following example, the corresponding host, user, password and file names should be specified.

Copy
<xsql-script>
    <body>
        <sftp host='host' user='xxx' password='yyyy'>
            <println>PWD   : <sftp.pwd /></println>
            <println>LIST  : <sftp.list /></println>
            <println>PUT   : test.dat -> test-remote1.dat</println>
            <sftp.put name='test-remote1.dat'>
                <file name='test.dat' type='absolute' />
            </sftp.put>
            <sftp.get name='test-remote1.dat' localname='test-from-remote.dat' />
            <println>LIST  : <sftp.list /></println>
            <println>EXISTS: test-remote1.dat:<sftp.exists name='test-remote1.dat' /></println>
            <println>RENAME: test-remote1.dat -> test-remote2.dat</println>
            <sftp.rename src='test-remote1.dat' dst='test-remote2.dat'/>
            <println>EXISTS: test-remote1.dat:<sftp.exists name='test-remote1.dat' /></println>
            <println>EXISTS: test-remote2.dat:<sftp.exists name='test-remote2.dat' /></println>
            <println>DELETE: test-remote2.dat</println>
            <sftp.delete name='test-remote2.dat' />
            <println>EXISTS: test-remote2.dat:<sftp.exists name='test-remote2.dat' /></println>
            <if>
                <expr>
                    <sftp.exists name='test' />
                </expr>
                <then>
                <println>EXISTS: dir test</println>
                </then>
                <else>
                    <sftp.mkdir name='test' />
                </else>
            </if>
            <println>LIST-F: <sftp.listFiles /></println>
            <iterator name='file'>
                <in>
                    <sftp.listFiles />
                </in>
                <do>
                    <println><sftp.file.getName><file /></sftp.file.getName></println>
                    <println><sftp.file.getSize><file /></sftp.file.getSize></println>
                    <println><sftp.file.isDirectory><file /></sftp.file.isDirectory></println>
                    <println><sftp.file.getTimestamp><file /></sftp.file.getTimestamp></println>
                </do>
            </iterator>
            <println>LIST-F: <sftp.listFilesAsResultSet /></println>
            <println>LIST-F: <sftp.listFilesAsResultSet raw='true' /></println>
        </sftp>
    </body>
</xsql-script>