in reply to Get filename of STDOUT

I have never tried out but you might find some solution in here: filenames from filehandles

pelagic