5

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?

Nev Stokes
  • 9,051
  • 5
  • 42
  • 44

1 Answers1

0

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()

Community
  • 1
  • 1
lebobbi
  • 2,147
  • 17
  • 20