Questions tagged [communicate]

129 questions
86
votes
3 answers

Understanding Popen.communicate

I have a script named 1st.py which creates a REPL (read-eval-print-loop): print "Something to print" while True: r = raw_input() if r == 'n': print "exiting" break else: print "continuing" I then launched 1st.py…
Black_Hat
  • 943
  • 1
  • 9
  • 12
29
votes
1 answer

Python subprocess Popen.communicate() equivalent to Popen.stdout.read()?

Very specific question (I hope): What are the differences between the following three codes? (I expect it to be only that the first does not wait for the child process to be finished, while the second and third ones do. But I need to be sure this is…
Christophe
  • 517
  • 2
  • 5
  • 9
24
votes
3 answers

Communicating between two threads

I have a thread, A which has a list. List holds some objects. Now I want to design a mechanisim by which I can send some message to thread A. Thread A runs in a loop (it does not wait or sleep). Some other thread, B, sends some message to thread A…
akshay
  • 5,235
  • 14
  • 39
  • 49
20
votes
3 answers

Capture "Segmentation fault" message for a crashed subprocess: no out and err after a call to communicate()

I have problems using the subprocess module to obtain the output of crashed programs. I'm using python2.7 and subprocess to call a program with strange arguments in order to get some segfaults In order to call the program, I use the following…
Tic
  • 421
  • 1
  • 5
  • 14
16
votes
1 answer

When should I use `wait` instead of `communicate` in subprocess?

In the document of wait (http://docs.python.org/2/library/subprocess.html#subprocess.Popen.wait), it says: Warning This will deadlock when using stdout=PIPE and/or stderr=PIPE and the child process generates enough output to a pipe such that it…
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237
11
votes
1 answer

Python3 subprocess communicate example

I'm new to subprocessing. I just need a really simple win32 example of communicate() between a parent.py and child.py. A string sent from parent.py to child.py, altered by child.py and sent back to parent.py for print() from parent.py. I'm posting…
Rhys
  • 4,926
  • 14
  • 41
  • 64
8
votes
2 answers

How to communicate between WPF and JavaScript in a WebBrowser instance?

I have a C#/WPF application with an embedded browser (WebBrowser) with some JavaScript. How can they communicate with each other in both directions? Is it practicable to use the URL? JS->WPF: Listen for changes. WPF->JS: Change the URL to…
koalabruder
  • 2,794
  • 9
  • 33
  • 40
7
votes
4 answers

Using Python to run executable and fill in user input

I'm trying to use Python to automate a process that involves calling a Fortran executable and submitting some user inputs. I've spent a few hours reading through similar questions and trying different things, but haven't had any luck. Here is a…
James
  • 167
  • 2
  • 2
  • 6
6
votes
1 answer

python 3 subprocess error in bytes

Very good, I have a little problem with the output of the thread, I get in unicode or I think and not let me convert it to utf-8, this is the code: import subprocess,sys,time string = b'dir' process = subprocess.Popen('cmd.exe',…
Francisco
  • 539
  • 2
  • 8
  • 25
5
votes
2 answers

PHP to Java communication

I want to use PHP to communicate with a java using shared database to communicate, please help me with sample code or logic. Thank you. EDIT: I appreciate your suggestions, Yes I will be using both php and java to connect to thesame database. The…
John
  • 61
  • 4
5
votes
1 answer

PyMySQL variables in queries

I would like to have a connection between my python code and a SQL database. I have read several ways to do it , but I am failing to get the results. conn = pymysql.connect(user=X,passwd=X,host=X,port=X,database=X, charset='utf8',…
Social Programmer
  • 147
  • 1
  • 4
  • 12
5
votes
1 answer

Python subprocess with stdout redirect returning an int

I am trying to read out data from a set of print statements in a C++ program that is being run using a subprocess. C++ code: printf "height= %.15f \\ntilt = %.15f \(%.15f\)\\ncen_volume= %.15f\\nr_volume= %.15f\\n", height,…
Elliot
  • 5,211
  • 10
  • 42
  • 70
4
votes
3 answers

Communicate Java and C#

I'm working on a project that uses an RFID reader, which only works with a library in C#. The thing is I'd really like to work with Java (develop the rest of the program, GUI, etc), and use the C# program just to ask the reader to read the…
4
votes
1 answer

Python: sequential calls to subprocess (in this case, espeak)

I was wondering if there was a way to access espeak as you might in the command line: laptop:~$espeak say this line first say this line second ... Right now, the only ways I can do it in python is process = subprocess.Popen(['espeak'],…
scarlet
  • 137
  • 7
4
votes
2 answers

Python's Popen + communicate only returning the first line of stdout

I'm trying to use my command-line git client and Python's I/O redirection in order to automate some common operations on a lot of git repos. (Yes, this is hack-ish. I might go back and use a Python library to do this later, but for now it seems to…
MikeTheTall
  • 3,214
  • 4
  • 31
  • 40
1
2 3
8 9