iDev
iDev

Reputation: 2433

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.

Upvotes: 1

Views: 141

Answers (2)

ikegami
ikegami

Reputation: 386501

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.

Upvotes: 1

ronnied
ronnied

Reputation: 106

Have you tried a backslash as an escape character?

Upvotes: 1

Related Questions