Pipes in Phing exec task

463 views Asked by At

I'm trying to implement a decent random string generator in my buildfile 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, it causes my build script to just hang when I try and call it from Phing. I've tried various escape patterns to no avail. What am I doing wrong?

1

There are 1 answers

0
lebobbi On

Try setting the escape to false. Also, you might want to try to use 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 the available options you can pass to exec.

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

And when should you use passthru.

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