Topic: nwauth authentication

hello i'm trying to authenticate with the server using the following function:


<?php
function nwauth ($nwserver, $user, $pass) {
  $command=sprintf("echo \"%s\" | /usr/local/surgemail/nwauth -S %s -U %s",  // parsing the
                    $pass, $nwserver, $user);          // command
    $out = array();                           // Just a dummy variable
    exec($command,$out,$err);                // *THE* meat!
    echo $err;
    print_r($out);
    if ($auth<>0){
      return 1; // failed authentication
    } else {
      return 0; // passed
    }
  }
?>

but always get the error 126.
there are another way?
anyone help me.
Thanks