Python Script

<< Click to Display Table of Contents >>

Navigation:  Actions > Script tools >

Python Script

Python is one of the most popular scripting languages today. It can be used for almost any task, including system administration and automation. There are many optional installation packages for a wide variety of tasks. You can find online documentation on Python here: https://www.python.org/doc/.

By default, Python Script action uses the preinstalled Python engine that comes with RoboTask. You can also use any other Python package installed and customized to your needs. The script can interact with RoboTask using the RoboTask object.

 

PythonScript1

 

Toolbar buttons

Save and Exit - saves task settings and closes the editor

Cancel - closes the editor without saving

Open - opens the script text from the external text file and places it into the script text editor.

Save as - saves the script text to an external file.

Add var - calls the variable selection window and places the variable call at the current cursor position.

 

Script Mode

There are two options

Execute inline script - execute the script you have written in the script editor. In this case, you will see the text editor.

Execute external script - run the script from an external file.

 

Expand variables

Check this box if you want to expand RoboTask variables in the script body before running the script. With variables, you can create dynamic text depending on different conditions.

 

Script

In "Execute inline script" mode, it is a script text editor.

In "Execute External script" mode, it is a field to enter the file name and a file selection button.

 

PythonScript2

 

Options

 

Assign exit code to a variable

Enter the variable name to save the script exit code. By default, the exit code is 0, but it can be changed in the script.

 

Assign script output to a variable

Enter a variable name in this field to write the script's output text stream to a variable. You will then be able to process this text in your task.

 

Python interpreter

Use Embedded Python - use the default Python engine that comes with RoboTask.

Use Specified Python - use your Python package. You can have several Python packages configured for different tasks.

 

Module search paths

Here you can set the search paths to additional Python modules (which are included in the script with the import command).

 

 

note Related Topics

RoboTask object for Python

JavaScript/Node.js script

RoboTask object for node.js

PowerShell script

JS script

JS Evaluate

VB Script

VB Evaluate

RoboTaskApp object