Difference between revisions of "User Scripts examples"

From Teltonika Networks Wiki
Tags: Mobile edit Mobile web edit
m
Line 1: Line 1:
 +
==Introduction==
  
 +
'''User Scripts''' is a service in RUT routers that provides the user with the possibility to create custom '''shell scripts''' that run at the end of router's boot process.
  
#!/bin/ash
+
This article will provide some examples on the usage of User Scripts. Although it must be noted that one should be at least be partially familiar with the syntax and basic principles of shell scripts beforehand as this guide will not provide a tutorial on shell scripts themselves.
HOST=10.10.10.10
+
 
if ping -c5 $HOST > /dev/null; then
+
==Example 1: 1-Wire Data to Server via HTTP==
  echo "$HOST responded; VPN is up!"
+
 
else
+
Since there is no Web interface support for getting 1-wire data, it has to be accessed via SSH or Console modes. As of now, the Data to Server function for 1-wire sensor data can only be done by writing a custom script since there are no direct methods of storing this data.
  echo "$HOST did not respond; trying to restart VPN"
+
 
  /usr/sbin/ipsec restart
+
 
 +
This article will provide a step-by-step configuration on how to configure data to server using a custom script that allows 1-wire data to be sent on an HTTP server.
 +
 
 +
 
 +
 
 +
 
 +
Connect to the TRB141 CLI via SSH or WebUI.
 +
 
 +
Create a new directory for you to save the script that is to be created later. (Optional)
 +
 
 +
Navigate to it, then create a new sh file using the “vi” command followed by the filename of your choice. (Don’t forget to add the .sh extension at the end).
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
==Example 2: filtering SMS messages==
 +
 
 +
[[File:Configuration examples user scripts 1.png]]

Revision as of 09:49, 6 April 2023

Introduction

User Scripts is a service in RUT routers that provides the user with the possibility to create custom shell scripts that run at the end of router's boot process.

This article will provide some examples on the usage of User Scripts. Although it must be noted that one should be at least be partially familiar with the syntax and basic principles of shell scripts beforehand as this guide will not provide a tutorial on shell scripts themselves.

Example 1: 1-Wire Data to Server via HTTP

Since there is no Web interface support for getting 1-wire data, it has to be accessed via SSH or Console modes. As of now, the Data to Server function for 1-wire sensor data can only be done by writing a custom script since there are no direct methods of storing this data.


This article will provide a step-by-step configuration on how to configure data to server using a custom script that allows 1-wire data to be sent on an HTTP server.



Connect to the TRB141 CLI via SSH or WebUI.

Create a new directory for you to save the script that is to be created later. (Optional)

Navigate to it, then create a new sh file using the “vi” command followed by the filename of your choice. (Don’t forget to add the .sh extension at the end).












Example 2: filtering SMS messages

Configuration examples user scripts 1.png