automated nfbtrans with expect: any suggestions

Cheryl Homiak chomiak at chartermi.net
Sat Sep 6 21:19:40 EDT 2003


Not sure this is the place to ask this but since people here use speech I
thought it might be relevant.
I've been trying to automate nfbtrans so that I can just have it
backtranslate a whole directory  of brf files to txt files without my
assistance.
With a change in one command, or with a partially interactive program,
though, this program could be used just as well for the other choices in
nfbtrans.
The program now works, though i'm sure the code could be better written;
this is my first attempt at using expect.
I also have no error protection in here; anybody using this would either
want to be sure there were no .txt files corresponding to the .brf files
in the directory before starting, or change the nfbtrans.conf so there
wouldn't be a warning about a file being overwritten.
My problem is that expect was starting a new sequence too soon and thus
files weren't being finished before expect apparently aborted nfbtrans and
started over, so the files weren't complete.
temporarily, I put in a "sleep" command so that each file would be
finished. However, it would be better if I could use a command whereby
expect would detect either that the file was completed or that nfbtrans
had exited (it exits after each file completion) rather than having an
arbitrary sleep time that could be too long or too short.
Any ideas?
Here's the program.
Thanks.

#!/bin/bash
for i in *.brf
do
i1=`basename $i .brf`.txt
expect -c "spawn /usr/local/bin/nfbtrans;send 3\r$i\r$i1\r;sleep 30"
done

-- 
Cheryl




More information about the Speakup mailing list