简体   繁体   中英

Executing a unix command from a php script (need to escape semicolon)

I am trying to call perl script with a parameter from a php script. The argument that a perl script takes contains a semicolon.

eg : perlfile <string;continuedstring>

If I use system("perfile <string;continuedstring> Unix interprets ; differently and shows an error.

Is there a way that I can escape ; so that unix interprets it as an argument.

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

I presume system takes a bourne shell command, in which case the command would your choice of

perlfile '<string;continuedstring>'

or

perlfile \<string\;continuedstring\>

You would invoke system as

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

or

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

respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM