title: Use a linux command in a Perl programm, and use Perl through php exec()
body: <p>I'm creating a system that allow me to create users automatically after an inscription. In this way, i've made a Perl script that generate a random password, crypt it with "mkpasswd" and then create an user with "useradd", after that user-infos are sended to a database.</p>
  
  <p>I've search documentation, and i've try to use the php exec function to call the Perl program.</p>
  
  <pre><code>$command = "/server/backoffice/scripts/usercreation.pl $username";
  exec($command, $result);
  print_r($result);
  </code></pre>
  
  <p>The usercreation.pl script work fine in a terminal, but for a unknown reason, it just not work from php, nothing happen, i know that the problem come from the useradd syntax or if not it come from the useradd command. The error value returned is 255 &lt;=> 0xff &lt;=> -1 .</p>
  
  <p>I think the problem come from the --password option of useradd, in fact, this option use mkpasswd and maybe it could disturb the shell or something else like that :p</p>
  
  <p>The complete useradd command used by the Perl program:</p>
  
  <pre><code>system("/usr/sbin/useradd $username -m -d $home --expiredate $expire --shell $shell --gid $gid --password $c_password");
  </code></pre>
  
  <p><strong>EDIT:</strong>
  The usercreation.pl file on pastebin (has been truncated to the part we are investigate):
  <a href="http://pastebin.com/DgFdndXf" rel="nofollow">http://pastebin.com/DgFdndXf</a></p>
  
  <p>The php one :
  <a href="http://pastebin.com/pQhADNzg" rel="nofollow">http://pastebin.com/pQhADNzg</a></p>
  
  <p>The web server used is nginx/0.7.65.</p>
  
  <p>The version of php used is PHP 5.3.3-1.</p>
  
  <pre><code>uname -a
  </code></pre>
  
  <p><code>Linux openco 2.6.35-32-generic #67-Ubuntu SMP Mon Mar 5 19:35:26 UTC 2012 i686 GNU/Linux</code></p>
  
  <p>Thanks for all!</p>