From: sc on
i am starting the process of automating the retrieval and
building of changes to vim using expect

my first [bash] script (named 't') performs an 'hg incoming'
to see if there are changes to the code -- it is coded as
follows:

<script>
#!/bin/bash
# test incoming for data or not, write to appropriate log
TMPFILE=$(mktemp -t testincoming.XXXXXXXX) || exit 1
cd ~/.build/hgvim/vim
date '+%Y-%b-%d %H:%M:%S' | tee -a $TMPFILE
hg incoming 2>&1 | tee -a $TMPFILE
dsh 40 | tee -a $TMPFILE
grep -q '^no changes found' $TMPFILE
if [ $? -eq 0 ]; then
cat $TMPFILE >> ../spare-incoming.log
else
cat $TMPFILE >> ../incoming.log
fi
rm $TMPFILE
</script>

when i execute 't' from the command line the correct incoming
log is appended to, but when executed as a spawned process it
is not

following is what i have so far in my expect script:

<script>
#!/usr/bin/expect
# the whole she-bang
# step one, [t]est hg incoming for changes
spawn t
expect {
"\nno changes found" { exit }
"\nchangeset" { expect eof }
}
puts "we've got changes, now we will proceed to get them"
</script>

any help will be appreciated

sc
From: sc on
sorry for the noise

sc wrote:

> when i execute 't' from the command line the correct incoming
> log is appended to, but when executed as a spawned process it
> is not
>
> following is what i have so far in my expect script:
>
> <script>
> #!/usr/bin/expect
> # the whole she-bang
> # step one, [t]est hg incoming for changes
> spawn t
> expect {

here we go

> "\nno changes found" { exit }
> "\nchangeset" { expect eof }
> }
> puts "we've got changes, now we will proceed to get them"
> </script>

fixing it to write to the log was as easy as adding 'expect eof'
to the "\nno changes found" pattern before the exit -- i was
exiting the the script before 't' had a chance to write to the
spare-incoming log