2

I am writing a test script for a C/S system in python. And right now, we only have a test client written in C#. It is a command line based client. I want to control the input and get the output of the client in my python script. How could I make it?

Thanks!

2 Answers 2

2

Use the subprocess module as follows:

import subprocess

proc = subprocess.Popen("cat", stdin = subprocess.PIPE, stdout = subprocess.PIPE)

out, err = proc.communicate(input)

The process ends after the last call. If you want to do some input iteratively, you can use proc.stdin.write, but you have to call communicate(None) at the end to finish the process.

Sign up to request clarification or add additional context in comments.

Comments

1

Use subprocess.Popen.

1 Comment

Hi,I know how to start the .net program using subprocess.Popen. But I do not know how to interact with the .net program with Popen. Could you give more details? Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.