Thanks, that helped a lot. I was able to get both sections of your code to work but using the GETENV command does not cause the stream to flush. I have also tried the SETENV command to see if that changes anything but the stream only seems to flush when I quit AFNI. I am currenlty using the code below in tcsh on OSX.
afni -yesplugouts | grep 'RAI xyz' > test.txt &
plugout_drive -quit\
-comm 'GETENV bogus'\
-comm 'SETENV AFNI_ENVIRON_WARNINGS NO'\
-comm 'GET_DICOM_XYZ'\
-comm 'GETENV bogus'\
-comm 'SETENV AFNI_ENVIRON_WARNINGS NO'
It saves the x, y, and z coordinates in test.txt but only after I have quit AFNI. Do you have another idea on how to flush the stream? I tried clicking some of the different opitions on the AFNI GUI itself but nothing changed anything. This has been a big help.
Thanks
Matthew