Example - Remote execution with Python 2.6 (or higher)

Skip to end of metadata
Go to start of metadata

Table of Contents

Introduction

The standard Python module multiprocessing got introduced in Python 2.6 and makes creating simple client/server applications extremely easy.

Here is an example that shows how to execute arbitrary commands remotely. Because it allows executing arbitrary commands it is probably a good idea to not use it exactly like this, but rather to extend it to do only exactly what you want it to do (like kill one specific application or so).

PLEASE NOTE
You can use this solution with any scripting language by running this Python based solution as an external process (see Article - Executing external applications). (See below for an example.)

But note that the Python installation running the os_system_server.py os_system_client.py scripts must be Python version 2.6 or higher.

You can download a package with the following three files here.

Example - Using os_system_client.py in Squish test scripts

Prerequisites:

  • Script os_system_client.py must reside in test suite directory
  • Script os_system_server.py must running on the remote computer (started like this: python os_system_client.py --server
test.js

Example - Using os_system_client.py without Squish

Prerequisites:

  • Script os_system_server.py must have been started on the remote computer

Executed in cmd.exe:

C:\Users\MyUser\Desktop> python os_system_client.py DIR
-----------------------------
Executing remotely: "DIR"
-----------------------------

[...]

Related information

Please note that there are platform specific tools, like PsExec which may be an option if you can limit yourself to the platform(s) supported by them.

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.