From c14e4d5da727f861aad5f91582710aee5a0ebeec Mon Sep 17 00:00:00 2001 From: m0n1b <161561830+m0n1b@users.noreply.github.com> Date: Fri, 29 Mar 2024 01:16:19 +0800 Subject: [PATCH] Update main.rs --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index b66f152..d8d6385 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::env; use std::io::{Read, Write}; use std::net::TcpStream; use std::process::{Command, Stdio}; +use std::str; fn main() { // 获取命令行参数 @@ -28,11 +29,11 @@ fn main() { // 连接关闭 break; } - let command = String::from_utf8_lossy(&buffer[..size]); + let command = str::from_utf8(&buffer[..size]).unwrap(); // 执行命令并捕获输出 let output = Command::new(executable_path) - .arg(&command) + .arg(command) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .output()