title: How to use an expect script from php webpage?
body: <p>When i try to execute a program from php5 on my debian, the webpage freeze and the program do nothing.
  This script works when i call it from the command line. Safe mode is disabled. Echo stdout doesnt work (because of the freeze).
  I read some answers in google which tells of www permissions but if someone here have a quick and simple response...</p>
  
  <p>How to debug this ?</p>
  
  <h2>The php call</h2>
  
  <pre><code>exec("expect scripts/sshtest.exp $module");
  </code></pre>
  
  <h2>The script code (which i found here <a href="http://bash.cyberciti.biz/security/expect-ssh-login-script/" rel="nofollow noreferrer">http://bash.cyberciti.biz/security/expect-ssh-login-script/</a>)</h2>
  
  <pre><code>#!/usr/bin/expect -f
  # set Variables
  set module [lrange $argv 0 0]
  set timeout -1
  # rsync 
  spawn rsync -aCb --progress --delete --backup-dir=/var/www/blabla.com/rsyncBackups/BackupedFilesFromServer23_on_  /var/www/blabla/$module  -e ssh root@10.10.10.10:/root/$module
  match_max 1000000
  # Look for passwod prompt
  expect "*?assword:*"
  # Send password 
  send -- "THEPASSWORD\r"
  # send blank line (\r) to make sure we get back to gui
  send -- "\r"
  expect eof
  </code></pre>