當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ssh2.Client類代碼示例

本文整理匯總了TypeScript中ssh2.Client的典型用法代碼示例。如果您正苦於以下問題:TypeScript Client類的具體用法?TypeScript Client怎麽用?TypeScript Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Client類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Client

    return new Promise<PromiseSFTP>((resolve, reject) => {
      const client = new Client();

      client.on("error", reject);
      client.on("ready", () => {
        client.sftp((err: Error, sftp: SFTPWrapper) => {
          if (err) {
            reject(err);
          }

          resolve(new PromiseSFTP(sftp, client));
        });
      });

      client.connect(config);
    });
開發者ID:linusnorton,項目名稱:uk-rail-import,代碼行數:16,代碼來源:PromiseSFTP.ts

示例2:

conn.on('ready', () => {
    console.log('Client :: ready');
    conn.forwardIn('127.0.0.1', 8000, (err: Error) => {
        if (err) throw err;
        console.log('Listening for connections on server on port 8000!');
    });
}).on('tcp connection', (info: any, accept: Function, reject: Function) => {
開發者ID:1drop,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:ssh2-tests.ts

示例3:

conn.on('ready', () => {
    console.log('Client :: ready');
    conn.subsys('netconf', (err: Error, stream: ssh2.ClientChannel) => {
        if (err) throw err;
        stream.on('data', (data: any) => {
            console.log(data);
        }).write(xmlhello);
    });
}).connect({
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:9,代碼來源:ssh2-tests.ts

示例4: parent

 conn2.exec('uptime', (err: Error, stream: ssh2.ClientChannel) => {
     if (err) {
         console.log('SECOND :: exec error: ' + err);
         return conn1.end();
     }
     stream.on('end', () => {
         conn1.end(); // close parent (and this) connection
     }).on('data', (data: any) => {
         console.log(data.toString());
     });
 });
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:11,代碼來源:ssh2-tests.ts

示例5:

conn.on('ready', () => {
    console.log('Client :: ready');
    conn.sftp( (err: Error, sftp: any) => {
        if (err) throw err;
        sftp.readdir('foo', (err: Error, list: any) => {
            if (err) throw err;
            console.dir(list);
            conn.end();
        });
    });
}).connect({
開發者ID:293yoshida,項目名稱:DefinitelyTyped,代碼行數:11,代碼來源:ssh2-tests.ts

示例6: initialize

function initialize() {
    conn = new Client();

    conn.on('ready', function () {
        console.log('conn::ready');
        conn.exec('gerrit stream-events', function (err, stream) {
            console.log('gerrit stream-events');
            if (err) {
                console.log('gerrit stream-events error', err);
                return reConnect();
            }
            stream.on('close', () => {
                console.log('stream::close');
            });
            stream.on('error', (err) => {
                console.log('stream::error', err);
            });
            stream.on('data', (data) => {
                console.log('stream::data', data + '');
                pushData(data);
            });
        });
    });
    conn.on('close', (hadError) => {
        console.log('conn::close');
    });

    conn.on('end', () => {
        console.log('conn::end');
    });

    conn.on('error', (err) => {
        console.log('conn::error', err + '');
        conn.end();
        reConnect();
    });

    connect();
}
開發者ID:adasq,項目名稱:gerrit-native-notifications,代碼行數:39,代碼來源:ssh-stream.ts

示例7: reject

      client.on("ready", () => {
        client.sftp((err: Error, sftp: SFTPWrapper) => {
          if (err) {
            reject(err);
          }

          resolve(new PromiseSFTP(sftp, client));
        });
      });
開發者ID:linusnorton,項目名稱:uk-rail-import,代碼行數:9,代碼來源:PromiseSFTP.ts


注:本文中的ssh2.Client類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。