title: how can I run a perl script which needs root?
body: <p>I need to execute a perl script located in /root/scripts/ from php using ssh from another computer or from the same computer. The thing is that I just don't know how to make php log into roots account to excecute only that file. </p>
  
  <p>As user$ I can't access /root/scripts/, so I can't call it using excec or system. I have tried using ssh to log into sudo su, and when I give my password it hangs.</p>
  
  <p>I leave the code here:</p>
  
  <pre><code>&lt;?php
  include('Net/SSH2.php');
  
  
  $ssh = new Net_SSH2('IP');
  if (!$ssh-&gt;login('user', 'password')) {
  exit('Login Failed');
  }else{
  echo ("login suscess");
  }
  echo $ssh-&gt;read(']$');
  
  echo $ssh-&gt;write("sudo su\n");
  
  echo $ssh-&gt;read('user:');
  //the code normally runs if I dont write the lines below
  
  $ssh-&gt;write('password\n');//here I try to get ssh the root pass but php wont respond after this
  echo $ssh-&gt;read('user]#');//normally this would work to show the root prompt  but I don't know what happens
  
  
  ?&gt;
  </code></pre>
  
  <p>I hope you can help me out here.</p>