How to use the RUN Component

Last updated: Nov 5th 2022

The RUN Output Component allows you to execute commands and programs when a barcode is scanned from your smartphone.

You can also run scripts using your favorite language, such as:

  • PHP
  • Python
  • Node
  • Batch scripts
  • Shell scripts
  • etc.

 

Executing commands

Follow this procedure:

  1. Drag & drop the RUN Component from the Available components field to the Output template field
  2. Put the command you want to execute in the Command field
  3. Save & Apply the server settings

 
Like this:

The output produced by the command can be used for the Keyboard Emulation feature, and for the Append to CSV file option.

 

Passing parameters

The RUN component allows you to pass the value of other components to your programs (or scripts) by using the double-curly braces syntax.

Command example: program.exe {{ barcode }}

Available variables list:

  • barcode
  • barcodes
  • number
  • text
  • timestamp
  • date_time
  • scan_session_name
  • device_name
  • select_option
  • http
  • run
  • csv_lookup
  • csv_update
  • javascript_function
  • woocommerce
  • google_sheets

 

☝️ Note: to use the variables listed above you must add the corresponding Output component before the RUN component in your Output Template.

 

For example if you want to use the number variable, your Output template should look like this:

output template

To prevent the NUMBER component affecting the Keyboard Emulation output you can click on it and enable the Skip output option.

 
 

Retrieving parameters in Python

You can use the following commands to trigger a Python script:
 
Windows: C:\Python37\python.exe C:\python.py {{ barcode }} {{ number }}
macOS or Linux: /usr/bin/python /python.py {{ barcode }} {{ number }}
 
Like this:

run_example
 

☝️ Note: the Python executable path may vary depending on your Python version and your OS. Use the py --list-paths command to determine the correct path.

To access the barcode and number variables you can use the following code:

 

Retrieving parameters in Node

You can use the following commands to trigger a Node script:
 
Windows: C:\Program Files\nodejs\node.exe C:\script.js {{ barcode }} {{ number }}
macOS or Linux: /usr/local/bin/node /script.js {{ barcode }} {{ number }}
 

To access the barcode and number variables you can use the following code:

 

Retrieving parameters in Shell Scripts

You can use the following command to run Shell script:
 
/bin/zsh /Users/YOUR_USERNAME/Desktop/my_script.sh {{ barcode }} {{ number }}
 
And read the parameters like this:

 

Retrieving parameters in Batch Files

You can use the following command to run Shell script:
 
cmd.exe /c C:\Users\YOUR_USERNAME\Desktop\my_script.bat {{ barcode }} {{ number }}
 
And read the parameters like this:

 

Executing MySQL queries

If the query is simple enough you can avoid using external scripts, and execute it using the MySQL Command-Line Client.
 
The command to use inside the RUN component is the following: mysql -u username -ppassword -N -B -e "query".
(Note: there is no space after the -p parameter)

 
Example: play a beep sound and show a message box when the scanned item is not found in the database:

Where the command inside the RUN component will look like this:

And the condition inside the IF component will look like this: run == "".

You can download the full working template: here.

 

Executing Microsoft SQL queries

As explained in the Microsoft Documentation you can connect to a SQL server using the sqlcmd utility.
The command to use inside the RUN component is the following:
 
sqlcmd -SmyServer\instanceName -Q "query"
 
For example, an INSERT query, will look like this: sqlcmd -Sserver0001\instance0001 -Q "INSERT INTO db.table (barcode) VALUES ('{{ barcode }}')"

 

☝️ Final Note and Tips

● Inside the command field you can put any command you want, but keep in mind that the working directory is set accordingly to your OS home directory.

● To avoid issues it’s suggested to always use absolute paths, for example:

Windows: C:\myprogram.exe
macOS or Linux: /my_executable

● If your path includes whitespace characters surround it with quotes ", like this:

"C:\Program Files\myprogram.exe" "C:\other folder\file.txt" "{{ barcode }}"

Comments

  1. Hi. I have downloaded the personal use version and am trying to get the run function to work with node prior to deciding whether or not to purchasing a license. The app seems to be very flexible and versatile. I have followed your instruction for node (copied and pasted the path and code and keep getting an error when I try to scan. Error. The RUN command failed. Output ‘C:\Program is not recognized as an internal or external command, operable program, or batch file. Exit status: 1 ok. I double checked the path the first time because I thought I must have not copied the entire path and that might have been the problem but the entire path was displayed in the run path input box. Any assistance would be greatly appreciated. Thanks.

    1. Hello,
       
      as already discussed by e-mail each path requires its own quote pair, like this:
      "C:\Program Files\nodejs\node.exe" "C:\script.js" "{{ barcode }}"

Your email address will not be published. Required fields are marked *

Related posts