|
Running custom scripts
Opengear console servers run the embedded Linux operating system and Administrator class users can configure the console server and monitor and manage attached serial console and host devices from the command line (refer faq 233). The Linux kernel in the console server also supports GNU bash shell script enabling the Administrator to write custom scripts - that can be run manually or automatically.
- Custom script can run when booting. The /etc/config/rc.local script runs whenever the system boots. By default this script file is empty. You can add any commands to this file if you want them to be run at boot time e.g. if you wanted to display hello world:
#!/bin/sh
echo "Hello World!"
If this script has been copied from a Windows machine you may need to run the following command on the script before bash can run it successfully:
# dos2unix /etc/config/rc.local
Another scenario would be to call another custom script from the /etc/config/rc.local file, ensuring that your custom script will run whenever the system is booted. In faq 334 the custom script uses this method to ping a target device and then power cycle the device in event of a ping request failure.
- Custom scripts can also be written so they run each time a particular alert triggers. Examples include:
- Power cycling a managed device on a particular alert event (refer faq 331)
- Send muliple notification emails out when an particular alert triggers (refer faq 332)
- You can also create custom scripts that run whenever a particular configurator has run (refer faq 336)
- Custom scripts can also be run manually from the command line (or called from other scripts). There are a number of specific function scripts that may be useful to the Administrator:
Bash commands
GNU bash, version 2.05.0(1)-release (arm-OpenGear-linux-gnu) supports the following shell commands:
alias [-p] [name[=value] ... ]
bg [job_spec]
bind [-lpvsPVS] [-m keymap] [-f fi break [n]
builtin [shell-builtin [arg ...]]
case WORD in [PATTERN [| PATTERN]
cd [-PL] [dir]
command [-pVv]
command [arg ...]
compgen [-abcdefjkvu] [-o option]
complete [-abcdefjkvu] [-pr] [-o o]
continue [n]
declare [-afFrxi] [-p] name[=value]
dirs [-clpv] [+N] [-N]
disown [-h] [-ar] [jobspec ...]
echo [-neE] [arg ...]
enable [-pnds] [-a] [-f filename]
eval [arg ...]
exec [-cl] [-a name] file [redirec]
exit [n]
export [-nf] [name ...] or export
false
fc [-e ename] [-nlr] [first] [last]
fg [job_spec]
for NAME [in WORDS ... ;] do COMMA
function NAME { COMMANDS ; } or NA
getopts optstring name [arg]
hash [-r] [-p pathname] [name ...]
help [-s] [pattern ...]
history [-c] [-d offset] [n] or hi
if COMMANDS; then COMMANDS; [ elif jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si
let arg [arg ...]
|
local name[=value] ...
logout
popd [+N | -N] [-n]
printf format [arguments]
pushd [dir | +N | -N] [-n]
pwd [-PL]
read [-ers] [-t timeout] [-p promp]
readonly [-anf] [name ...] or read return [n]
select NAME [in WORDS ... ;] do COMMANDS
set [--abefhkmnptuvxBCHP] [-o opti]
shift [n]
shopt [-pqsu] [-o long-option] opt
source filename
suspend [-f]
test [expr]
time [-p] PIPELINE
times
trap [arg] [signal_spec ...]
true
type [-apt] name [name ...]
typeset [-afFrxi] [-p] name[=value ulimit [-SHacdflmnpstuv] [limit]
umask [-p] [-S] [mode]
unalias [-a] [name ...]
unset [-f] [-v] [name ...]
until COMMANDS; do COMMANDS; done
variables - Some variable names an wait [n]
while COMMANDS; do COMMANDS; done { COMMANDS ; }
|
|