def execute_command_in_pipe(self, command, args=[], estdin=None, estdout=None):
        """ Execute a command by reading/writing input/output from/to optional
        streams like a pipe. After completion, return status """

        execfn = [command] + list(args)

        try:
            in_stream = False
            out_stream = False
            
            # Check if this is a stream
            if hasattr(estdin, 'read'):
                fpin = estdin
                in_stream = True
            elif type(estdin) in (str, unicode):
                fpin = open(estdin, 'r')
                in_stream = True
            if hasattr(estdout, 'write'):
                fpout = estdout
                out_stream = True
            elif type(estdout) in (str, unicode):
                fpout = open(estdout, 'w')
                out_stream = True
                
            if in_stream and out_stream:
                p = Popen(execfn, stdin=fpin, stdout=fpout, stderr=PIPE)
            elif in_stream and not out_stream:
                p = Popen(execfn, stdin=fpin, stdout=PIPE, stderr=PIPE)
            elif not in_stream and out_stream:
                p = Popen(execfn, stdin=PIPE, stdout=fpout, stderr=PIPE)
            elif not in_stream and not out_stream:
                p = Popen(execfn, stdin=PIPE, stdout=PIPE, stderr=PIPE)

            return p.wait()
            
        except Exception,e:
            print str(e)
                
        return -1
 Execute a command by reading/writing input/output from/to optional
        streams like a pipe. After completion, return status 
recipes/Python/498137_Minicommands_using_subprocess/recipe-498137.py