Software Content Management > Packages > Create a Package > File-Based Packages > Sample Scripts for File-Based Packages
Sample Scripts for File-Based Packages
ThingWorx Utilities provides sample scripts for the following package actions:
Running an application
Transferring a file from the agent to the ThingWorx Platform
Transferring a file to the agent from the ThingWorx Platform
Restarting the agent
Setting a property on the agent
You can download these sample scripts and save the scripts to the TW.RSM.Thing.FileRepository directory.
If you created a file-based package and added a sample script to be delivered to the agent, you can choose to modify the script when you create a deployment for the package. You must add the appropriate parameters and values for that script. The following table provides information about the parameters required for each sample script:
Deployment Action
Script Name
Parameters
Run an application
run_app_sample.lua
exec_path—The file system path (including the file name) of the application to be run.
Transfer a file from the agent to the ThingWorx Platform
transfer_from_agent_sample.lua
sourcePath—The relative path to the file, where the repository of the agent is the root.
sourceFile—The name of the file to transfer.
targetRepo—The name of the FileRepository on the ThingWorx Platform.
targetPath—The relative path to the location where the file will be transferred in the ThingWorx repository.
targetFile—The name of the file that will be created in the target repository.
Transfer a file to the agent from the ThingWorx Platform
transfer_to_agent_sample.lua
sourceRepo—The name of the FileRepository on the ThingWorx server.
sourcePath—The relative path to the file, where the ThingWorx repository is the root.
sourceFile—The name of the file to transfer.
targetPath—The relative path to the location where the file will be transferred on the agent.
targetFile—The name of the file that will be created on the agent.
Restart the agent
ems_restart_sample.lua
twems_service_name—The name of the service that the Edge MicroServer (EMS) has been registered under on the operating system of the agent.
Set a property on the agent
set_property_sample.lua
property_name—The name of the property being updated.
property_value—The value to set for the property.
Was this helpful?