57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
const { Client } = require('ssh2');
|
|
|
|
const config = {
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
};
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('SSH连接成功');
|
|
|
|
conn.exec('docker exec huishou find /usr/share/nginx/html/h5 -name "pages-order-list*"', (err, stream) => {
|
|
if (err) {
|
|
console.error('执行命令错误:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let output = '';
|
|
stream.stdout.on('data', (data) => {
|
|
output += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('容器内的order文件:');
|
|
console.log(output);
|
|
|
|
conn.exec('docker exec huishou grep -l "tabBar:" /usr/share/nginx/html/h5/assets/*.js', (err, stream) => {
|
|
if (err) {
|
|
console.error('执行命令错误:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let grepOutput = '';
|
|
stream.stdout.on('data', (data) => {
|
|
grepOutput += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('\n容器内包含tabBar调试信息的文件:');
|
|
console.log(grepOutput);
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.error('SSH连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect(config); |