Quick Start

Posted - Updated 2021-05-05
Supported on Linux, Aix, MacOS


So you just finish installing SADMIN tools and you want to see what it can bring to you. First you can take a look at the web interface at “http://yourserverIP” and you could run the two demo scripts “sadmlib_std_demo.sh” and “sadmlib_std_demo.py”. This will give you an idea of what functions you have access in our Library (sadmlib_std.sh and sadmlib_std.py) and how to use them. You can also run our template shell script and python template, take a look at the code, they are a good starting point to create your next shell or Python script.

Meet the templates

To create your own script using the SADMIN tools, you may want to take a look at the templates, run them and check their code. Check our tutorial page on using the shell template for a full example.

Shell script template

$SADMIN/bin/sadm_template.sh   

Running the template above, will show the kind of output we get on the screen, but also the log that is generated along with Result Code History file (.rch).

Python script template

$SADMIN/bin/sadm_template.py   

By looking at the script output you will notice that we get almost the same look, this is what we wanted, standardize the usage and the output. The Shell and the Python library have almost the same functions and both react the same way.

Create your own shell script

Make a copy of one of our template, modify it to your need and run it and see the result. Go an have a look at the log from the command line and from the web interface. Your script is now part of the web interface.

$ cp $SADMIN/bin/sadm_template.sh $SADMIN/usr/bin/newscript.sh
$ chmod 775 $SADMIN/usr/bin/newscript.sh
$ $SADMIN/usr/bin/newscript.sh

Run existing script with the wrapper

Use the SADMIN wrapper to run your existing script. Afterward, look at the log it produced in “$SADMIN/log” and the history file in “$SADMIN/dat/rch”. You can also go to the script section on the web interface and see the same information. The web interface is the central point to check your scripts logs and history file. If your script fail (exit with non zero value), it will appear on the monitoring page of the web interface. If you want it can also alert you when it fail or even it succeed, it is all up to you to decide (See SADM_ALERT variable).

$SADMIN/bin/sadm_wrapper.sh $SADMIN/usr/bin/yourscript.sh

SADMIN libraries in action

Learn how to use SADMIN Libraries by running the demos. Running the demo will give an idea of the functions available to you in your script and how to use them. In the script output, you see three columns, the first shows you how to call the function, the center column give you a brief description of the function and the last one give the result it returned when you ran it.

$SADMIN/bin/sadmlib_std_demo.sh 
$SADMIN/bin/sadmlib_std_demo.py

Terminal Menu & Tools Library

The screen below is an example of what you can easily do with the SADMIN screen library. You can use it to show a menu like below, it can have up to 30 items and the item are automatically positioning themselves to have one or two columns. It will accept user response and validate it for allowed values.

Run the following command to run the example script.

$ sadm_template_menus.sh

menuscreen1

You can accept data from the terminal, validate the content numeric, position the cursor at a particular line and column. The “sadm_mess()” function will show an error message to the user at the bottom of the screen and wait for a key to be press. The library include all sorts of functions that will save you time when building a user interface the terminal.

To have a complete list of functions available in the screen library, have a look at this page. To use use it in within your scripts, just add the command below.

source $SADMIN/bin/sadmlib_screen.sh 

This is it, you are now ready the use the SADMIN tool.