Hello,

I have a script that I use to run periodic updates of backups on to a
remote server.

Its a bash script, but it contains two expect blocks (the rsync command is
immediately after the spawn directive) :

VAR1=$(expect -c "
spawn
rsync -azuvWh --stats --exclude-from=$excludefile --include-from=$includefile --log-file
$rsynclogfile $username@$remotehost:$remoteroot/* $localroot
expect \"password:\"
send \"$passwd\r\n\"
expect \"speedup\"
send \"\r\n\"
")
VAR2=$(expect -c "
spawn
rsync -azuWh --progress --stats --delete --delete-excluded --exclude-from=$excludefile --include-from=$includefile --log-file
$rsynclogfile $localroot/ $username@$remotehost:$remoteroot
expect \"password:\"
send \"$passwd\r\n\"
expect \"speedup\"
send \"\r\n\"
")

This script keeps dying for no apparent reason at all (failure rate is
close to 90%, it tends to choke on large file transfers) :

2008/10/13 11:04:50 [17638] rsync error: received SIGINT, SIGTERM, or
SIGHUP (code 20) at rsync.c(271) [generator=2.6.9]
2008/10/13 11:04:51 [17735] building file list
2008/10/13 11:04:52 [17735] 20887 files to consider
2008/10/13 11:05:01 [17735] rsync error: received SIGINT, SIGTERM, or SIGHUP
(code 20) at rsync.c(271) [sender=2.6.9]

However, when I copy and paste the rsync command in a terminal (running
bash as well), substitute the various variables above with the values they
have inside the shell script, the rsync process runs without a hitch
(failure rate is maybe 5%).

Is there something about the way expect spawns processes that is causing
this ? I am forcing expect to wait for the "speedup" text, which comes in
at the end of a transfer (with the --stats option).


Thanks.

PS :

The reason I am using expect is that I do not know of a way to pass the
password (which I am reading from a local 400 permissions file) to rsync in
a bash script. Since the rsync occurs over ssh, the --password-file and
RSYNC_PASSWORD options do not work. The remote server is an AFS server,
which means that the /afs... share is mounted upon getting tokens, which
rules out passwordless RSA logins over ssh. Ubuntu Hardy's openafs-client
is broken, so I cannot even mount it using that. So, I have to use this
method of login.