Your script looks fine, but
as I stated elsewhere today, I have a script that works (my tech support wrote it for me) to ftp backup files to my other servers, but now I need to be able to get the script to log in as admin, then su to root, then run. What do I tell it? Here's what I am using now:
#!/usr/bin/expect -f
set root_pass "123456789"
set hostname "123.45.678.910"
set folder "/backup/cpbackup/daily"
spawn /usr/bin/scp -r $folder
[email protected]$hostname:/backup/servername/daily
sleep 3
expect "password: "
sleep 3
send "$root_pass\r"
interact