Huh. It seems to be taking me two tries to flush it, which I can't explain. But try this:
afni -yesplugouts | grep --line-buffered 'RAI xyz' | tee coords.txt&
{
echo GETENV bogus
while :; do
read -n1 -r -p $'\nPress "q" to quit or any other key to dump coordinates\n' 1>&2
if [ "$REPLY" == q ]; then
echo QUIT
break
fi
echo GET_DICOM_XYZ
echo GETENV bogus
echo GETENV bogus
done
} | plugout_drive &>/dev/null
Notice the --line-buffered option to grep, which is necessary to prevent the pipe to tee from turning on block buffering. (It turns out the previous command
would have eventually produced output without quitting-- but not until you'd instructed it to dump 64K worth of coordinates!)
EDIT: This is bash, and probably won't work on tcsh. But you can just run bash, copy the code in to run it, and then run "exit" to get out of bash and back to tcsh.
Edited 1 time(s). Last edit at 06/02/2015 05:44PM by Isaac Schwabacher.