Linksys E4200: reboot router using bash command

Cisco Linksys E4200 (and similar) is using web interface to administer router. You can simply use shell command to reboot and renew DHCP address instead of web interface.

Type the URL of Cisco web interface into web browser

http://192.168.1.1

Open the page and check for javascript code in HTML source. I’d like to reboot router so I’m looking for Java Script function named “reboot”:

function reboot(F)
{
	if(!confirm(other.warning))
		return;

        F.submit_button.value = "index";
        F.change_action.value = "gozila_cgi";
        F.submit_type.value="reboot";
        F.submit();
}

Use the command curl, add admin password with ‘-u’ option and join URL of web interface with ‘apply.cgi’ script. Using POST data from Java Script function construct shell command to its final version:

$ curl -u 'admin:Your-Password-Here' 'http://192.168.1.1/apply.cgi' -d "submit_button=index&change_action=gozila_cgi&submit_type=reboot"

Run this command to reboot router.

Linux: Colored Man Pages

Linux is my favorite operating system, especially gentoo distro. The command line is an awesome tool, but sometimes I’m missing the colors on black&white terminal. Yes, you can simply colorize the command ls or grep just adding the line

alias ls='ls --color=auto'

but how about the man pages ?

Man pages by default use less for displaying. So let’s go configure LESS to export bold and underline values of termcap:

export LESS_TERMCAP_mb=$'\E[01;31m'          # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m'  # begin bold
export LESS_TERMCAP_so=$'\E[38;5;246m'      # begin standout-mode - info box
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline
export LESS_TERMCAP_me=$'\E[0m'                 # end mode
export LESS_TERMCAP_se=$'\E[0m'                  # end standout-mode
export LESS_TERMCAP_ue=$'\E[0m'                  # end underline

Add the shell variables “LESS_TERMCAP_*” to gentoo configuration defined in /etc/env.d/70less or ~/.bashrc in general to work.

The ANSI escape sequence ’38;5;74m’ define xterm-256 foreground color with last number as a color index 0..255. Customize the colors as you like according to ANSI escape sequence.

Check if ANSI “color” escape sequences is enabled with parameter “-R” to LESS command:

$ env | grep LESS=
LESS=-R -M --shift 5

Check if man pages are rendered with color output. If not modify /etc/man.conf' and add switch ‘-c’ to NROFF configuration:

NROFF           /usr/bin/nroff -mandoc -c

Finally, you now see colored 'man ls' output:

NAME
       ls - list directory contents

SYNOPSIS
       ls [ OPTION ]... [ FILE ]...

DESCRIPTION
       List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape