本文整理汇总了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);
});
示例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) => {
示例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({
示例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());
});
});
示例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({
示例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();
}
示例7: reject
client.on("ready", () => {
client.sftp((err: Error, sftp: SFTPWrapper) => {
if (err) {
reject(err);
}
resolve(new PromiseSFTP(sftp, client));
});
});