From 12ad3c87fb66cb40c9f8b843235b78bd3df64915 Mon Sep 17 00:00:00 2001 From: xc Date: Thu, 9 Oct 2025 16:01:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=BB=84=E4=BB=B6=E4=BC=A0?= =?UTF-8?q?=E8=BE=93=E6=96=87=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scagent/core/FileRpc.go | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/scagent/core/FileRpc.go b/scagent/core/FileRpc.go index 73c1757..203727b 100644 --- a/scagent/core/FileRpc.go +++ b/scagent/core/FileRpc.go @@ -3,6 +3,7 @@ package core import ( "fmt" "net/rpc" + "os/exec" "path" "path/filepath" "scagent/config" @@ -90,36 +91,16 @@ func clientUploadFile(remote string, filePath string, uploadPath string) { logger := util.NewProductionLogger() defer logger.Sync() // 调用外部组件scalib 程序执行 - // ./scalib -h 192.168.66.92:9098 -f /www/gfs/sync_zips/BIU_20251009_153640.zip /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 -ip %s -port %s -file %s -upload %s", dstip, dport, filePath, uploadPath) + cmd := fmt.Sprintf("./scalib -h %s -f %s -u %s", remote, filePath, uploadPath) fmt.Printf("cmd: %s\n", cmd) - // 执行命令 - err := util.ExecCommand(cmd) + // 执行系统命令 + err := exec.Command(cmd).Run() if err != nil { logger.Error("ExecCommand failed", zap.Error(err)) fmt.Printf("ExecCommand failed: %v\n", err) return } - // 将服务器的信息拆分为ip和端口 - harr := strings.Split(remote, ":") - dstip := harr[0] - dport := harr[1] - - // 连接到RPC服务器 - service := fmt.Sprintf("%v:%v", dstip, dport) - client, err := NewUpFileClient(service) - if err != nil { - logger.Error("NewUpFileClient failed", zap.Error(err)) - } - defer client.rpcClient.Close() - // 调用 transferFile - err = transferFile(client, filePath, uploadPath) - if err != nil { - logger.Error("TransferFile failed", zap.Error(err)) - fmt.Printf("TransferFile failed: %v\n", err) - } - fmt.Printf("TransferFile success\n") - }