Pipes in the Phing exec task

I am trying to implement a nice random string generator in my build file using the following ExecTask

<exec command="cat /dev/urandom | tr -cd '[:alnum:]' | fold -w30 | head -n1" returnProperty="random" />

While this works fine when run on the command line, this leads to the fact that my build script just freezes when I try to call it from Phing. I tried various escape patterns to no avail. What am I doing wrong?

+4
source share
1 answer

Try setting escape to false. Alternatively, you can try using passthru.

<exec escape="false" passthru="true" command="cat /dev/urandom | tr -cd '[:alnum:]' | fold -w30 | head -n1" returnProperty="random" />

Here is the phing documentation, with options available that you can pass to exec.

https://www.phing.info/docs/guide/trunk/ExecTask.html

passthru.

PHP - exec() vs system() vs passthru()

0

All Articles