PHP-shell_exec grep,不使用变量
我有以下PHP代码片段,它将从Curl详细响应中提取IP,并将输出分配给变量(这非常有效): 我遇到的问题是,我试图使它搜索的文件成为动态文件,但它什么也不返回:PHP-shell_exec grep,不使用变量,php,grep,shell-exec,Php,Grep,Shell Exec,我有以下PHP代码片段,它将从Curl详细响应中提取IP,并将输出分配给变量(这非常有效): 我遇到的问题是,我试图使它搜索的文件成为动态文件,但它什么也不返回: $ipss = shell_exec("grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' curllog/$curlfile|head -1"); 当我回显$curl文件时,它会显示正确的文件名 我有另一个shell_exec,它使用一个变量,工作正常
$ipss = shell_exec("grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' curllog/$curlfile|head -1");
当我回显$curl文件时,它会显示正确的文件名
我有另一个shell_exec,它使用一个变量,工作正常:
shell_exec("wkhtmltoimage --crop-h 1080 --crop-w 1200 --load-error-handling ignore --quality 10 tmp/$htmlname tmp/$imagename");
我不明白为什么带有变量的grep不起作用。非常感谢您的任何意见 当前文件名($curlfile)是什么?如果我手动输入它,而不是我试图使用的变量,那么它的工作原理是完美的。向我们展示:echo“grep-o”[0-9]\{1,3\\\.[0-9]\{1,3\\.[0-9]\{1,3\.[0-9]\{1,3\\.[0-9]\{1,3\}curllog/$curlfile head 1”;grep-o'[0-9]\{1,3\\.[0-9]\{1,3\\\.[0-9]\{1,3\\\.[0-9]\{1,3\}curllog/10-08-2013_121004pm.txt | head-1@Jeremy那是另一个约会?顺便问一下,您确定在脚本执行时该文件已经存在吗?而不仅仅是在剧本之后?
shell_exec("wkhtmltoimage --crop-h 1080 --crop-w 1200 --load-error-handling ignore --quality 10 tmp/$htmlname tmp/$imagename");