这是我希望执行的命令.
php -r "apc_clear_cache(); apc_clear_cache('user'); apc_clear_cache('opcode');"
Run Code Online (Sandbox Code Playgroud)
这是我对phing的尝试
<exec command='php -r "apc_clear_cache(); apc_clear_cache(\'user\'); apc_clear_cache(\'opcode\');"' outputProperty="result" />
Run Code Online (Sandbox Code Playgroud)
这就是我得到的
BUILD FAILED
Error reading project file [wrapped: /var/virtual/abc.com/build.xml:171:26: > required]
Total time: 0.2093 seconds
Run Code Online (Sandbox Code Playgroud)
请指教.
更新:
我写称为bash脚本解决我的问题RunApcClearCache.sh,运行
php -r "apc_clear_cache(); apc_clear_cache('user'); apc_clear_cache('opcode');"
Run Code Online (Sandbox Code Playgroud)
然后使用调用bash脚本 ./RunApcClearCache.sh
如果有更好的方法,我想听听.
我也不愿意为一件如此简单的事情写一个任务.当然必须有一种方法可以在exectask中正确地避开双引号.
小智 5
Phing需要有效的XML.在有效的XML中,您不能直接在属性中使用.
你需要逃避/使用它的等效实体.有五个预定义的实体:
< represents "<"
> represents ">"
& represents "&"
' represents '
" represents "
Run Code Online (Sandbox Code Playgroud)
尝试使用实体而不是字符.所以使用"而不是"在命令属性内...
https://en.wikipedia.org/wiki/XML#Escaping