### Windows Command Line Installation Examples Source: https://docs.inductiveautomation.com/docs/8.1/getting-started/installing-and-upgrading/command-line-installations Use the `--%` argument before installer arguments for Windows. Examples show text-only installation and specifying a custom installation directory. ```bash C:\Users\yourUser\Downloads\ignition-8.1.14-windows-x64-installer.exe --% "textMode=true" ``` ```bash C:\Users\yourUser\Downloads\ignition-8.1.14-windows-x64-installer.exe --% "unattended=text" "location=C:\Ignition" ``` -------------------------------- ### macOS Command Line Installation Examples Source: https://docs.inductiveautomation.com/docs/8.1/getting-started/installing-and-upgrading/command-line-installations Use `open -a` with `--args` for macOS. Examples demonstrate text-only installation and setting a custom installation path. ```bash open -a /Volumes/IgnitionInstaller/ignition-8.1.14-osx-installer.app --args "textMode=true" ``` ```bash open -a /Volumes/IgnitionInstaller/ignition-8.1.14-osx-installer.app --args "unattended=text" "location=/Users/yourUser/Desktop/test" ``` -------------------------------- ### Linux Command Line Installation Example Source: https://docs.inductiveautomation.com/docs/8.1/getting-started/installing-and-upgrading/command-line-installations Use the `--` argument before installer arguments for Linux. This example shows a text-only installation. ```bash "/home/yourUser/Downloads/ignition-8.1.14-linux-x64-installer.run" -- "textMode=true" ``` -------------------------------- ### Example eam-install.properties for Agent Setup Source: https://docs.inductiveautomation.com/docs/7.9/enterprise-administration/agent-management/automated-agent-installation Specifies the installation type as 'Agent' and configures the controller server name and the interval for sending statistics to the controller. ```properties # installSelection: always set this setting to Agent setup.installSelection=Agent # controllerServerName: the Gateway Network server name of the controller agent.controllerServerName=Ubuntu-Controller # sendStatsInterval: the amount in seconds that the agent will wait before sending new metrics and configuration data to the controller. Note that if there are currently no interesting metrics or updated config data to send, the agent will not send any data. agent.sendStatsInterval=5 ``` -------------------------------- ### Start Text Installer in Graphical Environment Source: https://docs.inductiveautomation.com/docs/7.9/getting-started/quick-start-guide/download-and-install To start the text installer in a graphical environment on Linux, use this command. ```bash sudo ./ignition-X.X.X-linux-xxx-installer.run --mode text ``` -------------------------------- ### Controller Installation Configuration Source: https://docs.inductiveautomation.com/docs/8.1/ignition-modules/enterprise-administration/agent-management/automated-agent-installation Example eam-install.properties file for configuring a gateway as a controller. ```properties setup.installSelection=Controller controller.archivePath=path/to my backups controller.archiveLocation=Manual controller.lowDiskThresholdMB=1234 controller.dataSource=MyDB ``` -------------------------------- ### Agent Installation Configuration Source: https://docs.inductiveautomation.com/docs/8.1/ignition-modules/enterprise-administration/agent-management/automated-agent-installation Example eam-install.properties file for configuring a gateway as an agent. ```properties setup.installSelection=Agent agent.controllerServerName=Ubuntu-Controller agent.sendStatsInterval=5 ``` -------------------------------- ### Get Installed Module Names Source: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-getModules Retrieves all installed modules and prints their names. This example iterates through the dataset returned by system.util.getModules to extract and display the 'Name' of each module. ```Python #Return the names of all installed modules results = system.util.getModules() for row in range(results.rowCount): names = results.getValueAt(row, "Name") print names ``` -------------------------------- ### Windows Client Launcher Startup Example Source: https://docs.inductiveautomation.com/docs/7.9/clients/native-client-launchers Launches a client project in windowed mode on Windows. ```bash C:\ClientLauncher\clientlauncher.exe scope=C project=myproject windowmode=window ``` -------------------------------- ### Get and Open Windows Starting with 'Motor' Source: https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-vision/system-vision-getWindowNames This example demonstrates how to retrieve all window names using system.vision.getWindowNames and then open specific windows whose paths start with 'Motor'. It dynamically determines a motor number from the event source and passes it as a parameter to the opened windows. ```Python # This example would open windows that begin with "Motor" and pass in the currently selected motor number. motor = event.source.parent.number windows = system.vision.getWindowNames() for path in windows: if path[:5] == "Motor": system.vision.openWindow(path, {"motorNumber": motor}) ``` -------------------------------- ### Linux Client Launcher Startup Example Source: https://docs.inductiveautomation.com/docs/7.9/clients/native-client-launchers Launches a client project in fullscreen mode on Linux, specifying the screen and disabling the close button. ```bash ./clientlauncher.sh scope=C project=myterminal windowmode=fullscreen screen=0 show.closebutton=false ``` -------------------------------- ### Full Client Launcher Command Example (Linux) Source: https://docs.inductiveautomation.com/docs/7.9/clients/native-client-launchers Example of launching the client launcher from the Linux command line with scope, project, window mode, and custom launch parameters. ```bash ./clientlauncher.sh scope=C project=myterminal windowmode=window -Djavaws.launchparams="LaunchTag;LaunchTag2" -Djavaws.launchparam.LaunchTag="AAA" -Djavaws.launchparam.LaunchTag2="ZZZ" ``` -------------------------------- ### Starting the Ignition Gateway After Silent Installation Source: https://docs.inductiveautomation.com/docs/7.9/getting-started/installing-and-upgrading/installing After a silent installation, the Ignition Gateway does not start automatically. Use this command to start the Gateway service. ```bash net start ignition ``` -------------------------------- ### Set Current Date to Midnight Source: https://docs.inductiveautomation.com/docs/7.9/appendix/expression-functions/date-and-time/midnight This example demonstrates how to use the midnight() function to get the current date with the time set to midnight. No specific setup or imports are required as it uses the built-in now() function. ```expression midnight(now()) //This will take the current date and set the time to midnight ``` -------------------------------- ### Example: Download Perspective Workstation Launcher Source: https://docs.inductiveautomation.com/docs/8.1/launchers-and-workstation This is an example URL for downloading the 8.1.0 version of the Perspective Workstation launcher for Windows. ```text https://files.inductiveautomation.com/launchers/8.1.0/perspectiveworkstation.exe ``` -------------------------------- ### Image Component Configuration Example 1 Source: https://docs.inductiveautomation.com/docs/8.3/appendix/components/perspective-components/perspective-display-palette/perspective-image This example demonstrates setting the image source, fitting mode, tint color, and component dimensions. ```json { "props.source": "/system/images/Builtin/Flow/Flow 7.png", "props.fit.mode": "contain", "props.tint.enabled": true, "props.tint.color": "#FFF00", "position.width": 150, "position.height": 115 } ``` -------------------------------- ### Start Ignition Gateway on macOS Source: https://docs.inductiveautomation.com/docs/7.9/gateway/gateway-settings/gateway-setup Execute the ignition.sh script from the install directory with the 'start' parameter to manually start the Ignition Gateway service on macOS. The default install path is shown. ```bash /usr/local/ignition/ignition.sh start ``` -------------------------------- ### Run Initial Ignition Docker Container Source: https://docs.inductiveautomation.com/docs/8.1/platform/docker-image This command starts an Ignition container named 'example-gw' with specified data volume, environment variables for edition, EULA acceptance, admin password, port mapping, and container name. ```bash docker run --name example-gw -v example-gw-data:/usr/local/bin/ignition/data \ -e IGNITION_EDITION=standard -e ACCEPT_IGNITION_EULA=Y -e GATEWAY_ADMIN_PASSWORD=password \ -p 8088:8088 \ inductiveautomation/ignition:8.1.25 \ -n example-gw ``` -------------------------------- ### Create and Configure a New User with Various Properties Source: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-user/system-user-getNewUser Illustrates creating a new user, setting various properties like first name, last name, and password, managing contact information, roles, and schedule adjustments before saving the user. Includes a helper function to print responses. ```python # Util for printing the responses. def printResponse(responseList): if len(responseList) > 0: for response in responseList: print "", response else: print " None" # Make a brand new 'blank' user. Not saved until we save. user = system.user.getNewUser("", "myAwesomeUser") # Let's fill in some fields. Note we have two ways to access property names. user.set("firstname", "Naomi") user.set(user.LastName, "Nagata") user.set("password", "1234567890") # We can add contact info one at a time. Up to the script user to make sure the type is legit. user.addContactInfo("email", "naomi@roci.com") # We can add a lot of contact info. contactInfo = {"email":"ignition_user@mycompany.com","sms": "5551212"} user.addContactInfo(contactInfo) # We can delete contact info. Only deletes if both fields match. user.removeContactInfo("sms", "5551212") # We can add a role. If the role doesn't already exist, user save will fail, depending on user source. user.addRole("Mechanic") # We can add a lot of roles. roles = ["Administrator", "Operator"] user.addRoles(roles) # We can remove a role. user.removeRole("Operator") # We can add a schedule adjustment too. date2 = system.date.now() date1 = system.date.midnight(date2) user.addScheduleAdjustment(date1, date2, False, "An adjustment note") # We can make a bunch of adjustments and add them en-masse. date3 = system.date.addDays(date2, -4) adj1 = system.user.createScheduleAdjustment(date3, date2, True, "Another note") adj2 = system.user.createScheduleAdjustment(date3, date1, False, "") user.addScheduleAdjustments([adj1, adj2]) # and we can remove a schedule adjustment. All fields must match. user.removeScheduleAdjustment(date1, date2, True, "Some other note") # Finally, we will save our new user and print responses. response = system.user.addUser("", user) warnings = response.getWarns() print "Warnings are:" printResponse(warnings) errors = response.getErrors() print "Errors are:" printResponse(errors) infos = response.getInfos() print "Infos are:" printResponse(infos) ``` -------------------------------- ### Start Ignition Service Source: https://docs.inductiveautomation.com/docs/7.9/getting-started/installing-and-upgrading/installing Use this command to start the Ignition service after installation. ```bash /etc/init.d/ignition start ``` -------------------------------- ### Automated Ignition Installation on Linux Source: https://docs.inductiveautomation.com/docs/7.9/getting-started/installing-and-upgrading/installing Perform a silent, unattended installation of Ignition on Linux machines. The Gateway will not start automatically after a silent installation. ```bash sudo ./ignition-7.x.x-linux-x64-installer.run --mode unattended --prefix /somefolder/bin/ignition --unattendedmodeui none /etc/init.d/ignition start ``` -------------------------------- ### Open Desktop with Screen, Handle, and Window Source: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-gui/system-gui-openDesktop This example demonstrates creating a new desktop on a specific screen, assigning it a unique handle for scripting purposes, and opening a single window. The handle is crucial for referencing this desktop in other scripting functions. ```Python # Creates a new desktop on monitor 0 (primary) with only the Overview window open. # Including a handle gives the new desktop a name. This is useful for using other desktop scripting functions system.gui.openDesktop(screen=0, handle="Left Monitor", windows=["Overview"]) ``` -------------------------------- ### Example Gateway Network Configuration Source: https://docs.inductiveautomation.com/docs/8.3/appendix/reference-pages/platform-environment-variables Demonstrates how to configure multiple Gateway Network connections with host, port, and description. The '#' can be replaced with a number for each connection. ```bash GATEWAY_NETWORK_0_HOST=1.2.3.4 GATEWAY_NETWORK_0_PORT=8088 GATEWAY_NETWORK_0_DESCRIPTION="For tag server" GATEWAY_NETWORK_1_HOST=5.6.7.8 GATEWAY_NETWORK_1_PORT=8089 GATEWAY_NETWORK_1_DESCRIPTION="For edge server" ``` -------------------------------- ### Sending a Simple GET Request Source: https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-net/system-net-httpClient Example of creating a JythonHttpClient and sending a simple GET request, then validating the response. ```python # Create the JythonHttpClient. client = system.net.httpClient() # Send a GET request. response = client.get("https://httpbin.org/get", params={"a": 1, "b": 2}) # Validate the response. if response.good: # Do something with the response print response.json['args']['a'] ``` -------------------------------- ### Get substring between start and end index Source: https://docs.inductiveautomation.com/docs/7.9/appendix/expression-functions/string/substring Returns the portion of the string between the specified start and end indexes. Indexes are zero-based. ```expression substring("hamburger", 4, 8) //returns "urge" ``` -------------------------------- ### Get substring from start index Source: https://docs.inductiveautomation.com/docs/7.9/appendix/expression-functions/string/substring Returns the portion of the string starting from the specified index to the end of the string. Indexes are zero-based. ```expression substring("unhappy", 2) //returns "happy" ``` -------------------------------- ### Launch Perspective Project from Command Line (Windows) Source: https://docs.inductiveautomation.com/docs/8.3/launchers-and-workstation Use the 'start' command with a deep link to launch a Perspective project on Windows. The 'insecure=true' argument overrides the default HTTPS. ```bash start "perspective://localhost:8043/demo?insecure=true" ``` -------------------------------- ### GET Request Using an API Token Source: https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-net/system-net-httpClient Example of making a GET request with custom headers, specifically including an API token for authentication. ```python # Define the API Key URL to connect to. url = 'http://localhost:8088/data/api/v1/resources/names/com.inductiveautomation.opcua/device' # Add the API Token. headers = { 'X-Ignition-API-Token': 'API:KZFH8OAhqIInsGeFku7xw9eyJE2N940B_EbxtDHd1Vc', } # # Print the details of each item returned from the REST API, in this case describing device connections. response = system.net.httpClient.get(url, headers=headers) print response.json["items"] ``` -------------------------------- ### Get Current Date at Midnight Source: https://docs.inductiveautomation.com/docs/7.9/appendix/scripting-functions/system-date/system-date-midnight This example demonstrates how to get the current date and then use system.date.midnight to set its time to midnight, printing the result. ```Python # This example will print out the current date with the time set to midnight. date = system.date.now() print system.date.midnight(date) ``` -------------------------------- ### Launch Vision Client Launcher with a Configuration File Source: https://docs.inductiveautomation.com/docs/8.1/launchers-and-workstation/vision-client-launcher Example of launching the Vision Client Launcher and overriding its settings by pointing to a specific launcher configuration JSON file. ```bash "C:\ClientLauncher\visionclientlauncher.exe" config.json="C:\Users\MyUser\Desktop\vision-client-launcher.json" ``` -------------------------------- ### Agent Initialization Properties Source: https://docs.inductiveautomation.com/docs/8.1/ignition-modules/enterprise-administration/agent-management/automated-agent-installation Example init.properties file for configuring an agent's network settings and system name. ```properties SystemName=Agent1 AutoDetectLocal=false LocalInterface=10.20.11.17 UseSSL=false gateway.network.0.PingRate=1000 gateway.network.0.Enabled=true gateway.network.0.Host=10.20.11.18 gateway.network.0.Port=8088 gateway.network.0.EnableSSL=false gateway.network.0.PingTimeout=300 gateway.network.0.PingMaxMissed=30 gateway.network.0.EnableWebSockets=true gateway.network.0.WebsocketTimeout=10000 gateway.network.0.HttpConnectTimeout=10000 gateway.network.0.HttpReadTimeout=60000 ``` -------------------------------- ### Start Ignition Gateway Service (Windows Batch) Source: https://docs.inductiveautomation.com/docs/8.1/platform/gateway/gateway-command-line-utility-gwcmd This batch script starts the Ignition Gateway service on Windows. It is located in the Ignition installation directory. ```batch C:\Program Files\Inductive Automation\Ignition> start-ignition.bat ``` -------------------------------- ### Get and Close Window Source: https://docs.inductiveautomation.com/docs/7.9/appendix/scripting-functions/system-gui/system-gui-getWindow This example demonstrates how to get a reference to a window named 'Overview' and then close it. It includes error handling for cases where the window is not open. ```Python try: window = system.gui.getWindow('Overview') system.gui.closeWindow(window) except ValueError: system.gui.warningBox("The Overview window isn't open") ``` -------------------------------- ### Navigate to Home Screen Source: https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-vision/system-vision-goHome This example demonstrates how to use system.vision.goHome() in a button's script to navigate the user to the project's home screen. ```Python # This code would go in a button to move to the Home screen. system.vision.goHome() ``` -------------------------------- ### Example HTTP Request with API Key Source: https://docs.inductiveautomation.com/docs/8.3/platform/security/api-keys An example of a GET request to an API resource, demonstrating the inclusion of the API Key in the request header for authentication. ```http GET /api/resource HTTP/1.1 Host: your.gateway.address X-Ignition-API-Token: ``` -------------------------------- ### Add User Example Source: https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-user/system-user-addUser This example demonstrates how to create a new user, add contact information, set a password, and then add the user to a specific user source. ```APIDOC ## system.user.addUser(userSource, user) ### Description Adds a new user to a user source. Used in combination with getNewUser to create new user. ### Parameters #### Path Parameters - **userSource** (String) - Required - The user source to add a user to. If set to an empty string, the function will attempt to use the project's default user source (if called from a project). - **user** (User) - Required - The user to add, as a User object. Refer also to the PyUser class. ### Returns **UIResponse** - A UIResponse object which contains lists of the errors, warnings, and information returned after the add attempt. The contents of the lists are accessible from the getter methods. * `getWarns()` - Returns a list of warning messages that were encountered during the add. * `getErrors()` - Returns a list of error messages that were encountered during the add. * `getInfos()` - Returns a list of "info" messages that were encountered during the add. ### Scope Gateway, Vision Client, Perspective Session ### Code Examples Example #1 ```python # Get new user. userToGet = system.user.getNewUser("AcmeWest", "mTrejo") # Add some contact info. contactInfo = {"email":"mTrejo@acmewest.com","sms": "5551234"} userToGet.addContactInfo(contactInfo) userToGet.set("password", "thisIsMyPassword") # Adds a user to the the AcmeWest usersource. system.user.addUser("AcmeWest", userToGet) ``` ``` -------------------------------- ### Start Firefox and Open URL Source: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-execute Launches the Firefox browser and navigates to a specified URL. Note: This example may not work in Perspective Sessions due to web environment limitations. ```python # This code starts the Firefox browser and opens the Google home page. # Although system.util.execute() is also Perspective Session scoped, the following code snippet # will not work in a Perspective Session due to limitations of launching programs from a web environment. system.util.execute(['C:\\Program Files\\Mozilla Firefox\\firefox.exe', 'https://www.google.com']) ``` -------------------------------- ### Get and Close a Window Source: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-gui/system-gui-getWindow This example demonstrates how to get a reference to an open window named 'Overview' and then close it. It includes error handling for cases where the window is not found. ```Python # This example will get the window named 'Overview' and then close it. try: window = system.gui.getWindow('Overview') system.gui.closeWindow(window) except ValueError: system.gui.warningBox("The Overview window isn't open") ``` -------------------------------- ### Manually Input Gateway Address Examples Source: https://docs.inductiveautomation.com/docs/7.9/clients/native-client-launchers Examples of how to format the Gateway address when manually inputting it into the client launcher. This includes standard IP addresses, local connections, and SSL configurations. ```text // The following will connect to a Gateway using an IP address 10.10.10.1:8088 // The following will connect to a Gateway running on the local machine localhost:8088 // The following will connect to a Gateway using SSL 10.10.10.1:8088:8043 ``` -------------------------------- ### Get Username and Open Window Source: https://docs.inductiveautomation.com/docs/7.9/appendix/scripting-functions/system-security/system-security-getUsername This example demonstrates how to get the current username and use it to conditionally open different windows. It's suitable for startup scripts. ```python # This code would run on a startup script and does special logic based upon who was logging in name = system.security.getUsername() if name == 'Bob': system.nav.openWindow("BobsHomepage") else: system.nav.openWindow("NormalHomepage") ``` -------------------------------- ### Code Example Source: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-gui/system-gui-color An example demonstrating how to use system.gui.color to set a component's background color to red. ```Python # This example changes the background color of a component to red. myComponent = event.source myComponent.background = system.gui.color(255,0,0) # turn the component red ```