tags:

views:

34

answers:

1

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??

+4  A: 

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

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

Alberto Zaccagni
that's the deal! Thank a lot!
Informant
I'm glad that helped ;) Accept the answer if it solved your problem.
Alberto Zaccagni