Im trying to write a script that will change user to cyrus then reconstruct mailbox for the user defined in the parsed argument. If i was loggin in to terminal to do this manually for wendys mailbox i would do this
sudo su cyrus
/usr/bin/cyrus/bin/reconstruct -r user/wendy
That would reconstruct her mailboxes. Now i tried to do in a script using expect which i have never tried before heres my code
#! /usr/bin/expect -f
if [ ! $1 ]
then
echo "You must enter a user name!";
echo "Aborting!!";
exit 1;
fi
echo "changing to user cyrus"
spawn "su cyrus"
expect "#"
send "/usr/bin/cyrus/bin/reconstruct -r user/$1"
echo "reconstructed mailbox" $1
echo "finished"
exit 1;
However this gives me the following errors
why is spawn not found? isnt it a unix command or something? What shall i do next?