开发者

Run bash script in PHP results in syntax error

I can use the following bash script to start severals terminals at once:

for i in 0 1 2 3; do urxvt -name Terminal$i&; done

But if I try to run that bash script from a PHP script if fails with error:

sh: -c: line 0: syntax error near unexpected token `;'
sh: -c: line 0: `for i in 0 1 2 3; do urxvt -name Terminal$i&;开发者_开发问答 done'

PHP Script:

<?php
system('for i in 0 1 2 3; do urxvt -name Terminal$i&; done');
?>

This fails, too:

<?php
exec('for i in 0 1 2 3; do urxvt -name Terminal$i&; done');
?>

Without '&' no errors occurs but I want to start all in background. Escaping the '&' results in an invalid argument error of urxvt.

Any ideas??


Remove the ;, the & is the termination of the command.

Type man bash in your shell and look at "Lists" under the "SHELL GRAMMAR" section.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜