From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from remt24.cluster1.charter.net ([209.225.8.34]) by speech.braille.uwo.ca with esmtp (Exim 3.35 #1 (Debian)) id 19voDv-0006zS-00 for ; Sat, 06 Sep 2003 21:20:15 -0400 Received: from [66.168.18.11] (HELO maranatha.chartermi.net) by remt24.cluster1.charter.net (CommuniGate Pro SMTP 4.0.6) with ESMTP id 150237548 for speakup@braille.uwo.ca; Sat, 06 Sep 2003 21:19:41 -0400 Received: from chomiak (helo=localhost) by maranatha.chartermi.net with local-esmtp (Exim 3.36 #1 (Debian)) id 19voDM-0000n3-00 for ; Sat, 06 Sep 2003 20:19:40 -0500 Date: Sat, 6 Sep 2003 20:19:40 -0500 (CDT) From: Cheryl Homiak To: speakup Subject: automated nfbtrans with expect: any suggestions Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: speakup-admin@braille.uwo.ca Errors-To: speakup-admin@braille.uwo.ca X-BeenThere: speakup@braille.uwo.ca X-Mailman-Version: 2.0.11 Precedence: bulk Reply-To: speakup@braille.uwo.ca List-Help: List-Post: List-Subscribe: , List-Id: Speakup is a screen review system for Linux. List-Unsubscribe: , List-Archive: 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