Command Executor scripts connect your device to the Smart Control platform and allow it to receive and execute remote commands securely.
Supported platforms:
- Linux —
command-executor.sh - Windows —
command-executor.ps1
The script:
- Requests a command from the server
- Executes it locally
- Sends the result back
Server endpoint:
https://smart.udfsoft.com
On Linux, device_id is automatically taken from:
/etc/machine-id
The script already contains:
DEVICE_ID=$(cat /etc/machine-id)You can verify manually:
cat /etc/machine-idNo manual configuration is required.
On Windows, the PowerShell version generates the device ID automatically.
If needed, you can hardcode it:
$DEVICE_ID = "your-device-id"The API key is issued by the Smart Control platform.
Inside the script you will find:
API_KEY="xxxxxx"Replace xxxxxx with your actual API key:
API_KEY="your_real_key"To obtain an API key:
- Log in at: https://smart.udfsoft.com
- Create a new device using your
device_id - Generate and copy the API key
⚠ The API key is required. Without it, the server will return an authorization error.
Required tools:
- curl
- jq
- lscpu
- lsblk
- free
- sensors (optional)
Ubuntu / Debian:
sudo apt update
sudo apt install curl jq lm-sensors -ysudo mkdir -p /opt/smart-control
sudo cp command-executor.sh /opt/smart-control/
sudo chmod +x /opt/smart-control/command-executor.shEdit the file:
nano /opt/smart-control/command-executor.shReplace:
API_KEY="xxxxxx"With:
API_KEY="your_real_key"To run the script automatically every minute:
sudo crontab -eAdd:
*/5 * * * * /opt/smart-control/command-executor.sh >/dev/null 2>&1This means:
- Run every 5 minutes
Check cron:
sudo crontab -lRun PowerShell as Administrator:
Set-ExecutionPolicy RemoteSignedEdit command-executor.ps1:
$API_KEY = "your_real_key"- Open Task Scheduler
- Create a new task
- Trigger:
- Every 1 minute
- Action:
- Program:
powershell.exe - Arguments:
- Program:
-ExecutionPolicy Bypass -File "C:\path\command-executor.ps1"GET /api/v1/devices/commands?device_id=...
Headers:
X-DEVICE-ID
X-Api-Key
X-Platform
POST /api/v1/devices/commands/{COMMAND}
| Command | Description |
|---|---|
| SEND_CPU_INFO | CPU information |
| SEND_SENSORS_INFO | Temperature sensors |
| SEND_RAM_INFO | Memory usage |
| SEND_DISK_INFO | Disk information |
| SEND_BATTERY_INFO | Battery status |
| SEND_ALL_INFO | Full system report |
| Device Type | Interval |
|---|---|
| Server | 1–5 minutes |
| Workstation | 1–10 minutes |
| Laptop | 5–15 minutes |
- Keep your API key private
- Restrict file permissions
Linux:
chmod 600 command-executor.shWindows:
- Restrict NTFS file permissions
Run manually:
Linux:
/opt/smart-control/command-executor.shWindows:
.\command-executor.ps1If configured correctly, you should see:
[INFO] Command received
[INFO] Sending data...
[INFO] Done.
The script uses a pull-based model:
- The device polls the server
- The server returns a command
- The device executes it
- The device sends the result back
Advantages:
- No open ports required
- Works behind NAT
- Secure via API key
- Easy to scale