Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.

ULS Script writer's beginning guide

CYRO4S edited this page Apr 6, 2017 · 1 revision

Quick start

Writing ULS scripts is as same as writing Shell scripts. When you need to use ULS's built-in variables, use the keywords instead.
For example, if a ULS can only run as ROOT, you can use this:

if [[ sys.root == "false" ]]; then
    print("This script can only be run as ROOT")
    exit
fi

When using ULS's keywords,You don't need to add DOUBLE QUOTES,ULS will add them automatically. For example, sys.root will be converted into:
"true" or "false" when the script is executed.

Commands to run the scripts

Like Shell scripts, ULS scripts hava 2 ways to be executed:

  1. uls [ULS Script's Path]
  2. ./[ULS Script's Name]

Execution permission & interpreter declaration not needed when using the first way.
If you want to use the second way:

  1. Add interpreter declaration in the top of the script: #!/usr/bin/uls
  2. Add execution permission to the script: chmod +x [ULS Script's Name]

Provide One-Key command

Stay simple is important. If you provide a One-Key command to users, they will be happy.

"Download ULS script + Execute" One-Key command

wget [ULS Script's URL] && uls [ULS Script's Filename]
For example:
wget https://raw.githubusercontent.com/CYRO4S/ULS-Scripts/master/sysinfo.uls && uls sysinfo.uls

"Install ULS + Download ULS script + Execute" One-Key command

ULS may not installed on users' machine. You can create a Shell script to get installing, downloading & executing all together.

Let's create a shell script:

#!/bin/bash
wget https://raw.githubusercontent.com/CYRO4S/Universal-Linux-Script/master/uls_install.sh && bash uls_install.sh
wget [ULS Script's URL] && uls [ULS Script's Filename]

Then provide this command to users:
wget [Shell script's URL] && bash [Shell script's Filename]

Clone this wiki locally