Files
huishou/check-server-data.js
T
2026-07-27 13:37:48 +08:00

30 lines
928 B
JavaScript

const { Client } = require('ssh2');
const conn = new Client();
conn.on('ready', () => {
conn.exec('cat /www/huishou/server/data/stations.json', (err, stream) => {
if (err) { console.log('ERR:', err); conn.end(); return; }
let data = '';
stream.on('data', (d) => data += d.toString());
stream.on('close', () => {
console.log('服务器上的stations.json:');
console.log(data);
const json = JSON.parse(data);
const names = json.map(s => s.name);
console.log('\n站点名称列表:', names);
console.log('去重后:', [...new Set(names)]);
if (names.length !== [...new Set(names)].length) {
console.log('\n⚠️ 发现重复数据!');
} else {
console.log('\n✅ 数据没有重复');
}
conn.end();
});
});
});
conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });