fix: UPF脚本执行缺失expect声明

This commit is contained in:
TsMask
2023-10-25 20:19:13 +08:00
parent af610e4416
commit 36fcdb985d

View File

@@ -272,7 +272,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) {
if body.RunType == "start_str" {
fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId)
filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId)
scriptStr := "#!/bin/expect\n#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
scriptStr := "#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出避免弹出code 127
capCmdStr := fmt.Sprintf("%s file %s", body.Cmd, filePcapName)
@@ -303,7 +303,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) {
if body.RunType == "stop_str" {
fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId)
filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId)
scriptStr := "#!/bin/expect\n#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
scriptStr := "#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出避免弹出code 127
capCmdStr := body.Cmd