I figured out the --line-buffered option but I didn't think of having to do the GETENV command twice. I got it to work with the tcsh code below.
afni -yesplugouts | grep --line-buffered 'RAI xyz' > temp.txt &
plugout_drive -comm 'GET_DICOM_XYZ'\
-comm 'GETENV bogus'\
-quit
The big thing is that the temp.txt needs to be deleted each time. For some reason the stream is not flushed if the file already exists. Instead, the file is first overwritten so that it is blank and then the coordinates are only dumped after I quit AFNI.
With regards to the SET_OUTPLUG option, I updated my AFNI using @update.afni.binaries -d but this new option does not seem to be added. When I try to run it with plugout_drive I get this error: Can't drive AFNI with 'SET_OUTPLUG temp.txt'. This is the afni version that I am currently using
Precompiled binary macosx_10.7_Intel_64: May 31 2015 (Version AFNI_2011_12_21_1014)
Thank you all for your help.
Matthew