我需要一些帮助来逃避这个脚本中的引号,我有上面和下面的代码,但它不属于这个,因为如果我只是发出一个屏幕-d -m -S minecraft,它会创建一个罚款。任何帮助都会很棒,因为我现在已经尝试了一个小时,谢谢!
if (!($stream = ssh2_exec($con, 'screen -d -m -S minecraft -p 0 -X stuff "\printf "\say This is a test.\r"\"\' ))) {
echo "fail: unable to execute command\n";
} else {
// collect returning data from command
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
echo $data;
fclose($stream);
}
答案 0 :(得分:1)
\
不应该在"
之前。另外,根据你的描述,听起来你只想运行“screen -d -m -S minecraft”,看起来你在那里有一个额外的printf。
if (!($stream = ssh2_exec($con, "screen -d -m -S minecraft")))
答案 1 :(得分:0)
您只需将"\
更改为\"
。