Reputation: 515
I'd like to be able to use Cron to automate the execution of CopyConsole, the program that performs the synchronization of files on the server's Copy.com
The problem is that the execution is not terminates while the ENTER key is not pressed.
I've tried various forms of script, the best of all was this, but without success:
#!/bin/bash
timeout=600
expect() {
local expect="$1" send="$2"
local delim="${expect:(-1):1}"
local buffer="" block=""
while read -u3 -r -t$timeout -d "$delim" block; do
buffer="$buffer$block$delim"
case "$buffer" in
*"$expect")
echo "$send" 1>&3
return
;;
esac
done
}
exec 3<>/usr/local/copy.com/copy_sync.sh
expect "All Files Up To Date" "\r"
Can anyone help me find a solution, please? Thanks!
Upvotes: 2
Views: 201
Reputation: 515
SOLVED!
Have to use "#!/usr/bin/expect" and execute with "spawn"
#!/usr/bin/expect
set timeout 600
spawn /usr/local/copy.com/x86_64/CopyConsole -u=mail@copyaccount -r=/var/backups/copy.com -p=password
expect "All Files Up To Date" { send "\r"}
Thanks for comments.
Upvotes: 2