Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Using System and Environment Variables in your scripts

[Deleted User]
[Deleted User] Posts: 0 admin
edited February 2017 in Virtualize

You can use system/ environment variables in your scripts. Here is a simple example

from com.parasoft.api import *
from java.lang import System


def systemVariables (input, context):
    #This is for Windows
    Application.showMessage("COMPUTERNAME = " + str(System.getenv("COMPUTERNAME")))

    #This is for Linux
    #Application.showMessage("COMPUTERNAME = " + str(System.getenv("HOSTNAME")))

Here are a few nice web pages that provide what variables are available

Linux

http://man7.org/linux/man-pages/man7/environ.7.html

Windows

http://best-windows.vlaurie.com/environment-variables.html