timgolding
12-19-2008, 03:38 PM
im trying to get my php script to run expect like so....
if($_GET["action"]=="reconstruct" && isset($_POST["username"]))
{
if(array_key_exists($_POST["username"],$names))
{
$string = shell_exec("expect /home/scripts/reconstruct_mailbox.sh ".$_POST["username"]);
echo $string;
}
else
exit;
}
here is a copy of the reconstruct_mailbox.sh
#! /usr/bin/expect -f
set username [lindex $argv 0]
spawn su timgolding
expect "Password:"
send "secret\r"
expect "timgolding$"
send "sudo su cyrus\r"
expect "Password:"
send "secret\r"
expect "cyrus$"
send "/usr/bin/cyrus/bin/reconstruct -r user/$username\r"
expect eof
the expect script is working i have tested it in terminal
Im not sure if the php will be working because it was only outputting this
spawn su timgolding Password: mail:/Volumes/Files/webmaster/cyrus-admin/web timgolding$ sudo su cyrus Password: mail:/Volumes/Files/webmaster/cyrus-admin/web cyrus$ /usr/bin/cyrus/bin/recon
its as though it only got to "recon" and did it finish that line of code. Its annoying it was the last line of coed in the script. How can i tell. Is there some sort of a timeout i can set to get it to wait a little longer for output? Any ideas?
if($_GET["action"]=="reconstruct" && isset($_POST["username"]))
{
if(array_key_exists($_POST["username"],$names))
{
$string = shell_exec("expect /home/scripts/reconstruct_mailbox.sh ".$_POST["username"]);
echo $string;
}
else
exit;
}
here is a copy of the reconstruct_mailbox.sh
#! /usr/bin/expect -f
set username [lindex $argv 0]
spawn su timgolding
expect "Password:"
send "secret\r"
expect "timgolding$"
send "sudo su cyrus\r"
expect "Password:"
send "secret\r"
expect "cyrus$"
send "/usr/bin/cyrus/bin/reconstruct -r user/$username\r"
expect eof
the expect script is working i have tested it in terminal
Im not sure if the php will be working because it was only outputting this
spawn su timgolding Password: mail:/Volumes/Files/webmaster/cyrus-admin/web timgolding$ sudo su cyrus Password: mail:/Volumes/Files/webmaster/cyrus-admin/web cyrus$ /usr/bin/cyrus/bin/recon
its as though it only got to "recon" and did it finish that line of code. Its annoying it was the last line of coed in the script. How can i tell. Is there some sort of a timeout i can set to get it to wait a little longer for output? Any ideas?