29.04.2019 Views

OS6860(E)_AOS_8.1.1.R01_Switch_Management_Guide

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CLI Scripting<br />

Web Services, CLI Scripting, and OpenFlow<br />

CLI Scripting<br />

The <strong>AOS</strong> CLI relies on Bash scripting, it can be leveraged for creating CLI scripts without the need for an<br />

external tool. This Bash-based CLI allows users to perform high-level scripting work if necessary as given<br />

in the example below. This example illustrates simple example that creates multiple, non-contiguous,<br />

through the use of loops and variables. For instance:<br />

#!/bin/bash<br />

for vlanid in 1 2 3 4 10 15; do<br />

vlan $vlanid<br />

done<br />

Since the existing CLI infrastructure is being leveraged, the CLI's own security model is followed (Bash<br />

already authorizes commands based on partition management).<br />

Quoting and escaping<br />

Quotes (') and double quotes (") are used to enclose literal strings. Single quotes provide the most literal<br />

guard whereas double quotes will expand "$" variables. Due to this behavior, entering the text below will<br />

display "Hello" on a first row of the terminal, followed by "World" on the next row.<br />

echo 'Hello,<br />

World'<br />

Because literal mode single quotes were used pressing simply added that key's code to its literal<br />

string. Literal mode was exited with the closing single quote, which is why the second submitted<br />

the command to Bash.<br />

Backslash (\) is a continuation character. This means that the current line is continued on the next line.<br />

The example below will display “Hello World” on a single row:<br />

echo Hello,\<br />

World<br />

HEREDOC (

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!