Why is this a problem at all? There is no user supplied input here. There is some string mangling in commands below, but it looks like none of it can be manipulated by a malicious user. It's not a security issue. It sounds like OP just thinks that subprocesses are icky.