Send string to running process

This is the place for queries that don't fit in any of the other categories.

Send string to running process

Postby wwdw » Wed Apr 16, 2014 8:47 am


I have written a Python script (A) that runs the whole time as a "Server" and I need to send a string to Process A from another python script (B). The only functionality from B is to send a string to A when it is started. After sending the string, B is terminated but A should still running. Maybe B is started again after some time and sends again a string to A.......
What is the best way to do this? Should I use a (named) pipe, is it possible to use stdin or have I to use a socket, maybe TCP or UDP? Note: Both scripts run on the same machine.

Last edited by Mekire on Wed Apr 16, 2014 9:16 am, edited 1 time in total.
Reason: First post lock.
Posts: 1
Joined: Wed Apr 16, 2014 8:37 am

Re: Send string to running process

Postby setrofim » Sat Apr 19, 2014 3:34 pm

Sockets would be the way to go, either in their "raw" form, or over HTTP. In Python the easiest way to achieve this would be with Twisted in case of the former, or a micro framework such as Flask or Bottle in the latter. The other approaches you've named (named pipes, writing to server's stdin) may also work, but will be more limited and dependent on the underlying platform.
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 9 guests