Article View: alt.os.linux.ubuntu
Article #104rsync keeps failing from a bash/expect script
From: Geico Caveman
Date: Mon, 13 Oct 2008 18:16
Date: Mon, 13 Oct 2008 18:16
61 lines
3346 bytes
3346 bytes
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.
Technical Details
Message-ID:
<gd039o$pf0$1@aioe.org>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder.news-service.com!news.k-dsl.de!aioe.org!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1103af,849053ff8019e40c,start X-Google-Thread: 1054c0,849053ff8019e40c,start X-Google-Attributes: gid1103af,gid1054c0,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder.news-service.com!news.k-dsl.de!aioe.org!not-for-mail From: Geico Caveman <spammers-begone@spam.invalid> Newsgroups: alt.os.linux.ubuntu,comp.os.linux.misc,gnu.bash Subject: rsync keeps failing from a bash/expect script Followup-To: comp.os.linux.misc Date: Mon, 13 Oct 2008 11:16:23 -0700 Organization: Some Lines: 61 Message-ID: <gd039o$pf0$1@aioe.org> NNTP-Posting-Host: 7m/bMLn/s78rzm0tvBOLpg.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org NNTP-Posting-Date: Mon, 13 Oct 2008 18:16:24 +0000 (UTC) User-Agent: KNode/0.10.9