I have a custom authentication application that requires the user password to be provided via STDIN.
For example I can run this on the command line (in linux):

```
echo "P455w0rd" | authenticate -A username

```

The exit status is 0 or 1 and I need to use that to determine if the authentication passed or failed. The 'authenticate' app blocks on read from STDIN for the password. I can run the authenticate app from PHP with (edit):

```
$username = $_POST['username'];
$password = $_POST['password'];
// I need to run this shell command and provide the password via STDIN (how?)    
exec("authenticate -A $username", $output, $retval);

```

The exec blocks while the app waits for STDIN. How to I provide the password to the app from the PHP script? Will this work?

```
$username = $_POST['username'];
$password = $_POST['password'];
// I need to run this shell command and provide the password via STDIN (how?)
// Can I exec a background process and then fwrite to STDOUT?  
exec("authenticate -A $username &", $output, $retval);
fwrite(STDOUT, $password);

```