So I have this expect script that's worked fine for some time, but all of
a sudden it's quitting early on an scp file transfer when it used to wait
until completion. Here's the relevant procedure.
proc scp {tarball} {
global host user password directory
set scp "/usr/bin/scp"
if {! [file exists $tarball]} {
puts stderr "ERROR: $tarball does not exist."
exit 1
}
set timeout 60
puts "Copying tarball to sourceforge..."
spawn scp $tarball $user@$host:$directory
expect "password:" {
send "$password\r"
expect " 100% "
}
}
By expecting 100%, it's always picked up the progress reading, and moved
on when the scp was finished. Now it's stopping when the output reads...
opag.tar.gz 36% |********** | 952 KB 01:42
ETA
I don't see why it would stop here, but it's completely reproducable.
Any help appreciated,
Thanks,
Mike
--
Michael P. Soulier <msou...@storm.ca>, GnuPG pub key: 5BC8BE08
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort." -Harley Hahn, A Student's Guide to Unix
Should this be: spawn $scp ... , since you set that variable earlier?
[...]
> I don't see why it would stop here, but it's completely reproducable.
Is it reproducable only from the expect script, or from the command line too?
--
Glenn Jackman
gle...@ncf.ca
Michael> spawn scp $tarball $user@$host:$directory
Michael> expect "password:" {
Michael> send "$password\r"
Michael> expect " 100% "
Michael> }
Michael> By expecting 100%, it's always picked up the progress
Michael> reading, and moved on when the scp was finished. Now it's
Michael> stopping when the output reads...
Michael> opag.tar.gz 36% |********** | 952 KB 01:42
Michael> ETA
Michael> I don't see why it would stop here, but it's completely
Michael> reproducable.
I don't have a good answer for you, but whenever I have tried to
automate something which may be sending escape sequences to the
screen, I've tried to find a way to use interact.
I tried running autoexpect with something like the above scp command
(except I usually have ssh-agent running in the background). It
appears that scp is printing the entire line and doesn't get a newline
until the copy is completely finished. If that's the case, then
something like this might do the trick for you
spawn scp $tarball $user@$host:$directory
expect "password:" {
send "$password\r"
interact "\n"
}
or possibly try the -nobuffer option to interact
spawn scp $tarball $user@$host:$directory
expect "password:" {
send "$password\r"
interact -nobuffer "\n"
}
roland
--
PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD RL Enterprises
rol...@rlenter.com 76-15 113th Street, Apt 3B
rol...@astrofoto.org Forest Hills, NY 11375
Perhaps it's hitting your self-imposed 60 second timeout?
Don
Y'know, I forgot I even did that. I'll bet that's what it is...
Thanks, I'll go get a coffee now. ;-)