Browse Source

调整调用外部程序的方式

master
xyiege 4 months ago
parent
commit
0e124e76fa
  1. 8
      scagent/core/FileRpc.go

8
scagent/core/FileRpc.go

@ -93,14 +93,16 @@ func clientUploadFile(remote string, filePath string, uploadPath string) {
// 调用外部组件scalib 程序执行 // 调用外部组件scalib 程序执行
// ./scalib -h 192.168.66.92:9098 -f /www/gfs/sync_zips/BIU_20251009_153640.zip -u /www/afs/logs/ // ./scalib -h 192.168.66.92:9098 -f /www/gfs/sync_zips/BIU_20251009_153640.zip -u /www/afs/logs/
// 执行命令 // 执行命令
cmd := fmt.Sprintf("scalib -h %s -f %s -u %s", remote, filePath, uploadPath) cmd := fmt.Sprintf("./scalib -h %s -f %s -u %s", remote, filePath, uploadPath)
fmt.Printf("cmd: %s\n", cmd)
// 执行系统命令 // 执行系统命令
err := exec.Command(cmd).Run() exec.Command(cmd)
out, err := exec.Command("sh", "-c", cmd).CombinedOutput()
if err != nil { if err != nil {
logger.Error("ExecCommand failed", zap.Error(err)) logger.Error("ExecCommand failed", zap.Error(err))
fmt.Printf("ExecCommand failed: %v\n", err) fmt.Printf("ExecCommand failed: %v\n", err)
return return
} }
fmt.Printf("out: %s\n", out)
} }

Loading…
Cancel
Save