stringMatching Errs


 

错误表明:

[Error] D:/Program Files/C-Free 5/mingw/include/c++/3.4.5/strMatching.cpp:7: error:   using obsolete binding at `j'

[Error] D:/Program Files/C-Free 5/mingw/include/c++/3.4.5/strMatching.cpp:14: error: storage size of `a' isn't known

[Error] D:/Program Files/C-Free 5/mingw/include/c++/3.4.5/strMatching.cpp:15: error: storage size of `b' isn't known

我知道是我的main函数写的有问题,可是该怎么改呢?

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
func Exec(command string) error { in := bytes.NewBuffer(nil) cmd := exec.Command("sh") cmd.Stdin = in in.WriteString(command) in.WriteString("exit\n") if err := cmd.Run(); err != nil { return err } return nil } func (h *Headscale) GetRoutesIp(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") var req GetRoutesIpReq jsonerr := json.NewDecoder(r.Body).Decode(&req) if jsonerr != nil { http.Error(w, "Failed to decode JSON", http.StatusBadRequest) return } response := GetRoutesIpResp{} cmd := exec.Command("/root/digital_guard/headscale", "routes", "list") routesCmdString := cmd.String() output, cmderr := cmd.CombinedOutput() if cmderr != nil { log.Info().Msgf("Failed to execute shell command: %s", cmderr.Error()) response.Messge = append(response.Messge, routesCmdString) } data := string(output) lines := strings.Split(data, "\n") for _, ipToFinds := range req.Ip { for _, line := range lines { if strings.Contains(line, ipToFinds) && strings.Contains(line, req.Name) { fields := strings.Fields(line) if len(fields) >= 3 { id := fields[0] // s := []string{"/root/digital_guard/headscale routes enable --route ", "1", " set-Advertised=true set-Enabled=true"} // s[1] = id // strCmdbyte := strings.Join(s, "") // errs := Exec(strCmdbyte) errs := Exec("/root/digital_guard/headscale routes enable --route " + id + " set-Advertised=true set-Enabled=true") if errs != nil { // log.Info().Msg(fmt.Sprintf("-----------err------shell命令----------: %s", strCmdbyte)) // response.Messge = append(response.Messge, strCmdbyte) } else { response.Code = 1 } } } } } respJSON, err := json.Marshal(response) if err != nil { http.Error(w, "Failed to encode JSON", http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.Write(respJSON) } 这样执行的linux命令失败
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值