That's a nice idea, I still think 3dAutobox (again, probably with -noclust) would be the fastest. To get around having to create a new dset, you could do:
#!/bin/tcsh
# get the full, formatted string
set aaa = `3dAutobox -noclust -extent -input PIL.nii`
# get just the "P=..." piece of the output (always the 7th, even if dataset is resampled), and the get just the number part (3rd character and after)
set just_coord = `echo ${aaa[7]} | awk '{print substr($0,3)}'`
echo "++ The posterior coord is: ${just_coord}"
--pt