【问题标题】:Executing a unix command from a php script (need to escape semicolon)从 php 脚本执行 unix 命令(需要转义分号)
【发布时间】:2013-07-28 22:04:34
【问题描述】:

我正在尝试使用 php 脚本中的参数调用 perl 脚本。 perl 脚本采用的参数包含一个分号。

eg : perlfile <string;continuedstring>

如果我使用system("perfile &lt;string;continuedstring&gt; Unix 以不同方式解释 ; 并显示错误。

有没有办法让我逃脱 ; 以便 unix 将其解释为参数。

【问题讨论】:

    标签: php unix system


    【解决方案1】:

    我认为system 采用了 bourne shell 命令,在这种情况下,您可以选择该命令

    perlfile '<string;continuedstring>'
    

    perlfile \<string\;continuedstring\>
    

    你会调用system as

    system("perlfile '<string;continuedstring>'");
    

    system("perlfile \\<string\\;continuedstring\\>");
    

    分别。

    【讨论】:

    • 感谢您的帮助!反斜杠有帮助!
    【解决方案2】:

    您是否尝试过使用反斜杠作为转义字符?

    【讨论】:

    • 谢谢! Backslask 帮了大忙!
    • 没问题。很高兴我能帮上忙。
    猜你喜欢
    • 1970-01-01
    • 2012-09-19
    • 1970-01-01
    • 2023-03-06
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-29
    相关资源
    最近更新 更多