Command Line Interface

https//www.racom.eu/eng/products/m/midge1/CLI.html

Print version

8. Command Line Interface

The Command Line Interface (CLI) offers a unified control interface to the router and can be used to get/set configuration parameters, apply updates, restart services or perform other system tasks.

The CLI should be started using cli -i command from system shell or when logging as root user. A list of available commands can be displayed by running cli -l. It will be started automatically in interactive mode when logging in as admin user.

$ cli
Name:
        cli (Command Line Utility)

Usage:
         [-ilvh] <command>
~ $ cli -i
MIDGE Command Line Interface (version 0.2)
(C) Copyright RACOM s.r.o, Czech Republic

Enter 'help' for a list of available commands
or hit the TAB key for auto-completion.

Ready to serve. 

>

The CLI supports the TAB completion, that is expanding entered words or fragments by hitting the TAB key at any time. This applies to commands but also to arguments and generally offers a convenient way for working on the shell.

Please note that each CLI session will perform an automatic logout as soon as a certain time of inactivity (10 minutes by default) have been reached. It can be turned off by the command no-autologout.

The CLI can be exited by running exit.

8.1. General usage

When operating the CLI in interactive mode, each entered command will be executed by the RETURN key. You can use the Left and Right keys to move the current point between entered characters or use the Up and Down keys to search the history of entered commands. Pressing CTRL-c twice or CTRL-d on an empty command line will exit the CLI.

List of supported key sequences:

Key SequenceAction
CTRL-aMove to the start of the current line.
CTRL-eMove to the end of the line.
CTRL-fMove forward a character.
CTRL-bMove back a character.
ALT-fMove forward to the end of the next word.
ALT-bMove back to the start of the current or previous word.
CTRL-lClear the screen leaving the current line at the top of the screen, with an argument given refresh the current line without clearing the screen.
CTRL-pFetch the previous command from the history list, moving back in the list.
CTRL-nFetch the next command from the history list, moving forward in the list.
ALT-<Move to the first line in the history.
ALT->Move to the end of the input history.
CTRL-rSearch backward starting at the current line and moving up through the history.
CTRL-sSession will be frozen.
CTRL-qReactivate frozen session.
CTRL-dDelete character at point or exit CLI if at the beginning of the line.
CTRL-tDrag the character before point forward moving point forward as well. If point is at the end of the line, then this transposes the two characters before point.
ALT-tDrag the word before point past the word after point, moving point over that word as well. If point is at the end of the line, this transposes the last two words on the line.
CTRL-kDelete the text from point to the end of the line.
CTRL-yYank the top of the deleted text into the buffer at point.

Please note, that it can be required to apply quotes (“) when entering commands with arguments containing whitespaces.

The following sections are trying to explain the available commands.

8.2. Print help

The help command can be used to get the list of available commands when called without arguments, otherwise it will print the usage of the specified command.

> help
Usage:
        help [<command>]

Available commands:

        get                  Get config parameters
        set                  Set config parameters
        update               Update system facilities
        cert                 Manage keys and certificates
        status               Get status information
        scan                 Scan networks
        send                 Send message, mail, techsupport or ussd
        restart              Restart service
        debug                Debug system
        reset                Reset system facilities
        reboot               Reboot system
        shell                Run shell command
        help                 Print help for command
        no-autologout        Turn off auto-logout
        history              Show command history
        exit                 Exit

8.3. Getting config parameters

The get command can be used to get configuration values (not the current values).

get -h
Usage:
        get [-hsvfc] <parameter> [<parameter>..]

Options:
        -s        generate sourceable output
        -v        validate config parameter
        -f        get factory default rather than current value
        -c        show configuration sections

See the following example for reading configuration DIO values:

> get dio.out1
dio.out1=on
> get dio.out2
dio.out2=on

8.4. Setting config parameters

The set command can be used to set configuration values.

> set -h
Usage:
        set [-hv] <parameter>=<value> [<parameter>=<value>..]

Options:
        -v     validate config parameter

See the following example for setting configuration digital output values. Both values will be “off” and both values will be also “off” after the next start-up procedure.

> set dio.out1=off
> set dio.out2=off

8.5. Updating system facilities

The update command can be used to perform various system updates.

> update -h
Usage:
        update [-hfrsnbv] <software|config|firmware|license|sshkeys> <URL>

Options:
        -r     reboot after update
        -f     force update
        -n     don't reset missing config values with factory defaults
        -b     update backup config
        -s     show update status

Available update targets:

        software           Perform software update
        firmware           Perform module firmware update
        config             Update configuration
        license            Update licenses
        sshkeys            Install SSH authorized keys

8.6. Manage keys and certificates

The update command can be used to manage keys and certificates.

> cert -h
Usage:
        cert [-h] [-p phrase] <operation> <cert> [<url>]

Possible operations:

        install           install a certificate from specified URL
        create            create a certificate locally
        enroll            enroll a certificate via SCEP
        erase             erase an installed certificate
        view              view an installed certificate

8.7. Getting status information

The status command can be used to get various status information of the system.

> status -h
Usage:
        status [-hs] <section>

Options:
        -s     generate sourceable output

Available sections:

        summary              Short status summary
        info                 System and config information
        config               Current configuration
        system               System information
        configuration        Configuration information
        license              License information
        storage              Storage
        wwan                 WWAN module status
        wlan                 WLAN module status
        gnss                 GNSS (GPS) module status
        eth                  Ethernet interface status
        lan                  LAN interface status
        wan                  WAN interface status
        openvpn              OpenVPN connection status
        ipsec                IPsec connection status
        pptp                 PPTP connection status
        gre                  GRE connection status
        dialin               Dial-In connection status
        mobileip             MobileIP status
        dio                  Digital IO status
        audio                Audio module status
        can                  CAN module status
        uart                 UART module status
        redundancy           Redundancy status
        sms                  SMS status
        firewall             Firewall status
        qos                  QoS status
        neigh                Neighborhood status
        location             Current location
        users                Active users
        hotspot              Hotspot status
        bgp                  BGP status
        ospf                 OSPF status

In the following example, we read the current DIO values. Remember that the current states do not correspond to the configuration values set with “set dio.out” commands.

> status dio
=== DIGITAL IO INFORMATION ===
IN1:                             off
IN2:                             on
OUT1:                            on
OUT2:                            off

8.8. Scan

The scan command can be used to scan the mobile network for the possible networks. Note that the active mobile connection will be deactivated during the scan procedure.

> scan -h
Usage:
        scan [-hs] <interface>

Options:
        -s     generate sourceable output

Available interfaces:

        Mobile1    (wwan0)

See the example below:

> scan -s Mobile1

NETWORK1_NAME="EUROTEL - CZ"
NETWORK1_LAI="23002"
NETWORK1_RAT="GSM"
NETWORK1_SERVICE="CSD"
NETWORK1_STATUS="Current"

NETWORK2_NAME="vodafone CZ"
NETWORK2_LAI="23003"
NETWORK2_RAT="GSM"
NETWORK2_SERVICE="CSD"
NETWORK2_STATUS="Forbidden"

NETWORK3_NAME="T-Mobile CZ"
NETWORK3_LAI="23001"
NETWORK3_RAT="GSM"
NETWORK3_SERVICE="CSD"
NETWORK3_STATUS="Forbidden"

NETWORK_COUNT="3"

8.9. Sending e-mail or SMS

The send command can be used to send a message via E-Mail/SMS to the specified address or phone number.

> send -h
Usage:
        send [-h] <type> <dest> <msg>

Options:
        <type>     type of message to be sent (mail, sms, techsupport, ussd)
        <dest>     destination of message (mail-address, phone-number or argument)
        <msg>      message to be sent

8.10. Restarting services

The restart command can be used to restart system services.

> restart -h
Usage:
        restart [-h] <service>

Available services:

        configd              Configuration daemon
        dnsmasq              DNS/DHCP server
        dropbear             SSH server
        firewall             Firewall and NAPT
        gpsd                 GPS daemon
        gre                  GRE connections
        ipsec                IPsec connections
        lighttpd             HTTP server
        link-manager         WAN links
        network              Networking
        openvpn              OpenVPN connections
        pptp                 PPTP connections
        qos                  QoS daemon
        smsd                 SMS daemon
        snmpd                SNMP daemon
        surveyor             Supervision daemon
        syslog               Syslog daemon
        telnet               Telnet server
        voiced               Voice daemon
        vrrpd                VRRP daemon
        wlan                 WLAN interfaces
        wwan-manager         WWAN manager

8.11. Debug

The debug command can be used to display individual daemons debugging output.

> debug -h
Usage:
        debug [-hr] [-l <level>] <target>

Options:
        -l <level>      set debug level
        -r              reset debug level

Available debug targets:

        system
        scripts
        ubxd
        rrsp11
        rrsp12
        configd
        watchdog
        swupdate
        wwan-manager
        led-manager
        event-manager
        link-manager
        wwanmd
        surveyor
        mobile-node
        home-agent
        voiced
        smsd
        sdkhost
        ser2net
        qosd
        gpsd
        rrsp2
        rrsp21

8.12. Resetting system

The reset command can be used to reset the router back to factory defaults.

> reset -h
Usage:
        reset [-h] [facility]

Available reset facilities:

        factory              Reset system to factory defaults
        statistics           Reset link statistics

8.13. Rebooting system

The reboot command can be used to reboot the router.

> reboot -h
Usage:
        reboot [-h]

8.14. Running shell commands

The shell command can be used to execute a system shell and run any arbitrary application.

> shell -h
Usage:
        shell [-h] [<cmd>]

8.15. CLI commands history

The history command displays the history of CLI commands entered on the unit.

> history 
   1  help
   2  get -h
   3  get dio.out1
   4  set dio.out1=off
   5  set dio.out2=off
   6  set dio.out1=on
   7  get dio.out1
   8  get dio.out2
   9  set -h

8.16. CLI–PHP

CLI-PHP, an HTTP front-end to the CLI application, can be used to configure and control the router remotely. It is enabled in factory configuration, thus can be used for deployment purposes, but disabled as soon as the admin account has been set up. The service can later be turned on/off by setting the cliphp.status configuration parameter:

> get cliphp.status
cliphp.status=0

> set cliphp.status=1
> get cliphp.status
cliphp.status=1
          cliphp.status=0           Service is disabled
          cliphp.status=1           Service is enabled

This section describes the CLI-PHP interface for Version 2, the general usage (GET requests) is defined as follows:

Usage:
    http (s)://cli.php?<key1>=<value1>&<key2>=<value2>..<keyN>=<
    valueN>
Available keys:
output             Output format ( html, plain )
usr                Username to be used for authentication
pwd                Password to be used for authentication
commandV           Command to be executed
arg0..arg31        Arguments passed to commands
Notes:
    The commands correspond to CLI commands as seen by 'cli −l', the arguments
   (arg0..arg31) will be directly passed to the cli application 

    Thus, an URL containing the following sequence:

      command=get&arg0=admin.password&arg1=admin.debug&arg2=admin.access

   will lead to cli being called as:

    $ cli get "admin.password" "admin.debug" "admin.access"

    It supports whitespaces but please be aware that any special characters in the URL
    must be specified according to RFC1738 (which usually done by common clients such
    as wget, lynx, curl).

Response:
    The returned response will always contain a status line in the format:

    <return>: <msg>

    with return values of OK if succeeded and ERROR if failed. Any output from the
    commands will be appended

Examples:

    OK: status command successful
    ERROR: authentication failed

status – Display status information

Key usage:
        command=status[&arg0=<section>]
Notes:
        Available sections can be retrieved by running command=status&arg0=−h.
        System status can be displayed without authentication.

Examples:

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&command=
status&arg0=−h
http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&command=
status&arg0=summary
http://192.168.1.1/cli.php?version=2&output=html&command=status

get – Get configuration parameter

Key usage:

        command=get&arg0=<config−key>[&arg1=<config−key>..]

Examples:

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=get&arg0=config.version

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=get&arg0=openvpn.status&arg1=snmp.status&arg2=ipsec.status

set – Set configuration parameter

Key usage:
     command=set&arg0=<config−key>&arg1=<config−value>[&arg2=<config
     −key>&arg3=<config−value>..]
Notes:
     In contrast to the other commands, this command requires a set
     of tuples because of the reserved '=' char, i.e.
     [arg0=key0, arg1=val0], [arg2=key1, arg3=val1], [arg4=key2, arg5=val2], etc

Examples:


http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=set&arg0=snmp.status&arg1=1

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=set&arg0=snmp.status&arg1=0&arg2=openvpn.status&arg3=1

restart – Restart a system service

Key usage:
     command=restart&arg0=<service>
Notes:
     Available services can be retrieved by running 'command=restart&arg0=−h'

Examples:


http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=restart&arg0=−h

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=restart&arg0=link−manager

reboot – Trigger system reboot

Key usage:
     command=reboot

Examples:


http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&command=reboot

reset – Run factory reset

Key usage:
     command=reset

Examples:


http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&command=reset

update – Update system facilities

Key usage:
     command=update&arg0=<facility>&arg1=<URL>
Notes:
     Available facilities can be retrieved by running 'command=update
&arg0=−h'

Examples:

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=127
admin01&command=update&arg0=software&arg1=tftp://192.168.1.254/latest

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=update&arg0=config&arg1=tftp://192.168.1.254/user−
config.zip

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=
admin01&command=update&arg0=license&arg1=http://192.168.1.254/xxx.lic

send – Send SMS

Key usage:
     command=send&arg0=sms&arg1=<number>&arg2=<text>
Notes:
     The phone number has to be specified in international format such
as +123456789 including a leading plus sign (which can be encoded with %2B).
The SMS daemon must be properly configured prior to using that function.

Examples:

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01
&command=send&arg0=sms&arg1=%2B123456789&arg2=test

send – Send E-Mail

Key usage:
     command=send&arg0=mail&arg1=<address>&arg2=<text>
Notes:
     The address has to be a valid E−Mail address such as abc@abc.com 
(the at−sign can be encoded with %40). The E−Mail client must be properly
configured prior to using that function.

Examples:

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&
command=send&arg0=mail&arg1=abc%40abc.com&arg2=test

send – Send TechSupport

Key usage:
     command=send&arg0=techsupport&arg1=stdout
command=send&arg0=techsupport&arg1=<address>&arg2=<subject>
Notes:
     The address has to be a valid E−Mail address such as abc@abc.com 
(the at−sign can be encoded with %40). The E−Mail client must be properly
configured prior to using that function. In case of stdout, the downloaded
techsupport file will be called 'download'.


Examples:

http://192.168.1.1/cli.php?version=2&output=mime&usr=admin&pwd=admin01&
command=send&arg0=techsupport&arg1=stdout

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&
command=send&arg0=techsupport&arg1=abc%40abc.com&arg2=subject

send – Send USSD code

Key usage:
     command=send&arg0=ussd&arg1=<card>&arg2=<code>
Notes:
     The argument card specifies the card module index (e.g. 0 for wwan0 ).
The USSD code can consist of digits, plus signs, asterisks 
(can be encoded with %2A) and dashes (can be encoded with %23).


Examples:

http://192.168.1.1/cli.php?version=2&output=html&usr=admin&pwd=admin01&
command=send&arg0=ussd&arg1=0&arg2=%2A100%23

©  2024 RACOM s.r.o. All Rights Reserved.