ThingWorx Software Content Management > Packages > Create a File-based Package > Sample Scripts for File-based Packages
Sample Scripts for File-based Packages
ThingWorx Utilities provides 5 sample scripts for the following package actions:
Run an application
Transfer a file from the agent to the ThingWorx Platform
Transfer a file to the agent from the ThingWorx Platform
Restart the agent
Set a property on the agent
You can download these scripts from here and save the scripts to the TW.RSM.Thing.FileRepository directory.
While creating a file-based package, if you added a sample script to be delivered to the agent, you can choose to modify the script when you create a deployment. You need to 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 being executed.
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 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 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 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?