Update app.js
This commit is contained in:
@@ -37,17 +37,31 @@ app.get("/re", (req, res) => {
|
||||
});
|
||||
|
||||
app.get("/rp", (req, res) => {
|
||||
const changeportCommands = "cd ~ && bash webport.sh";
|
||||
exec(changeportCommands, (err, stdout, stderr) => {
|
||||
const changeportCommands = "cd ~ && env && bash webport.sh"; // 打印环境变量,帮助调试
|
||||
|
||||
exec(changeportCommands, { maxBuffer: 1024 * 1024 * 10 }, (err, stdout, stderr) => {
|
||||
// 打印标准输出和错误输出
|
||||
console.log('stdout:', stdout);
|
||||
console.error('stderr:', stderr);
|
||||
|
||||
// 错误处理
|
||||
if (err) {
|
||||
console.error('Execution error:', err);
|
||||
return res.status(500).send(`错误:${stderr || stdout}`);
|
||||
}
|
||||
|
||||
// 如果有标准错误,返回错误信息
|
||||
if (stderr) {
|
||||
console.error('stderr output:', stderr);
|
||||
return res.status(500).send(`stderr: ${stderr}`);
|
||||
}
|
||||
|
||||
// 返回正常的输出
|
||||
res.type('text').send(stdout);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
app.get("/list/key", (req, res) => {
|
||||
const listCommands = `
|
||||
USERNAME=$(whoami | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
Reference in New Issue
Block a user