I want to trigger my python script remotely, but don't really want to expose any Web or other interface, eg. I need some passive way. One of the ways I can think of is by sending e-mail, then server can receive it and run the script. It is highly desirable to have an open console window on Ubuntu and then run the script, so I can see the output and progress if it lasts long and I will have direct access to it. But if not possible, then only running script would be enough, I'll think how to redirect output into file.
procmail is one way to automatically run a script when e-mail gets received. Another way is to define a new mail alias, say, firstname.lastname@example.org and make that just run a script. For example, in Postfix you would put to aliases something like
Then just add necessary safe belts to your Python script so it won't automatically execute the software every time a new mail arrives to that box; make the script examine the mail body for keywords, or do something else.
Screen, what's that? Good old screen is here to help you for your monitoring needs. Just run your script with
Then you can login to your server and attach to that screen with
and when you are done watching progress, press
procmail is the usual way of approaching this. Set it up for a specific user, write the relevant procmail recipe and then mail to that user can trigger anything you like.
Some people will suggest alternatives to procmail since it hasn't been in active development for quite some time - however, it also works very well.