[Tutor] pass argument into running program *outside* of program

Kent Johnson kent37 at tds.net
Thu Aug 21 23:10:03 CEST 2008


On Thu, Aug 21, 2008 at 4:34 PM, James <jtp at nc.rr.com> wrote:

> I have a program that I am writing that will be shared amongst
> multiple users. This program sits in the background as a daemon and
> 'does' things (consider it a black box). I want users to be able to
> SSH into the Linux box that is running the code and then do something
> like this:
>
> $ program.py addMe <username> <var2>
>
> In other words, a user will 'pass' something (an argument, for a lack
> of better words) into the program that is *already* running, and the
> program will modify its behavior based on that command.

One possibility is for the daemon to be listening on some kind of
socket. A web server is one example; in that case the users could load
a web page to change the behaviour. Another simple way to do this
would be for the daemon to be an xml-rpc server; your addMe program
would make an rpc call to the server. This is easy to do with the
Python standard library. For example see
http://blog.doughellmann.com/2008/06/pymotw-simplexmlrpcserver.html
http://blog.doughellmann.com/2008/07/pymotw-xmlrpclib.html

Kent


More information about the Tutor mailing list