in reply to Origin of 'md5sum' and 'sh' logs

Any thoughts on where to look for trouble shooting this error, or maybe some kind of explanation of why the -e command is generating these md5sum and sh logs?

It isn't. Whatever is generating that output is not in the code you have shown. You should reduce your entire code to the smallest possible script which does generate those errors (an SSCCE) and provide that if you want more help to debug it. Without that, we can only guess (although my money is on one of either a race condition or more likely the $filepath in your subroutine isn't the path you think it is).

In the meantime, check out the Basic debugging checklist.