I am trying to issue a command in python and read the input and parse it back. This is the command i am trying to issue (example when running on the command line)
-bash-3.2$ echo "passthru TST,1234" | ./vsh -a 127.0.0.1 -p 7000
PASSTHRU TST,1234
udp_send_command: timed out waiting for response
-bash-3.2$
I am trying to use python subprocess
            vsh_command = ' "passthru ' + cmd + '" | ./vsh -a ' + ip_address + ' -p ' + port
            print vsh_command
            new_command = ['echo', vsh_command]
            print new_command
            proc = subprocess.Popen(new_command,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    stdin=subprocess.PIPE,
                    shell=True)
            print '1'
            out_2, err = proc.communicate()
            print out_2
            print '2'
            rcv = out_2.splitlines()
            print '3'
            for r in rcv:
                    print '     ' + r
            print '4'
`
 "passthru TST,1234" | ./vsh -a 127.0.0.1 -p 7000
['echo', ' "passthru TST,1234" | ./vsh -a 127.0.0.1 -p 7000']
1
2
3
4
Is a | command not possible with subprocess? if so is there another way that i can run this shell command and get the input?
UPDATE: (With single string for shell=true command)
`vsh_command = 'echo "passthru ' + cmd + '" | ./vsh -a ' + ip_address + ' -p ' + port
            print vsh_command
            proc = subprocess.Popen(vsh_command,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    stdin=subprocess.PIPE,
                    shell=True)
            print '1'
            out_2, err = proc.communicate()
            print out_2
            print '2'
            rcv = out_2.splitlines()
            print '3'
            for r in rcv:
                    print '     ' + r
            print '4'
`
Run (python script)
echo "passthru TST,1234" | ./vsh -a 127.0.0.1 -p 7000
1
PASSTHRU TST,1234
2
3
     PASSTHRU TST,1234
4
SUCCESS
Still not quite what im looking for, looks like its just doing the echo command not the pipe
EDIT #2
            p = Popen(["./vsh", "-a", ip_address, "-p", str(port)],stdin=PIPE, stdout=PIPE)
            out, err =  p.communicate("passthru TST,1234")
            print '----------'
            print out
Output:
-bash-3.2$ python mfd_ascii_test.py
udp_send_command: timed out waiting for response
----------
PASSTHRU TST,1234
-bash-3.2$
out is the result of the echo, not the 'udp_send_command: timed out waiting for response'
 
     
     
     
    