Translate

Archives

Efivars and Efivarfs

This post demonstrates how to use both the new efivarfs filesystem and older efivars mechanism to create, read, write and delete (U)EFI variables.

Fedora 18 Supports 256 Color Terminals

You may not be aware of it but currently Linux terminal emulators such as xterm only supports 8 colors while those on Apple’s OS X support 256 colors. Now, beginning with Fedora 18, Fedora will also support 256 colors via the xterm-256color terminfo database entry. To see how many colors a terminal supports: $ echo $TERM xterm-256color $ tput colors 256 I have never liked the default colors produced by the –color color option to ls and other utilities and, as a result, have normally removed such aliases from my bash startup scripts. Having 32 times more colors available gives

Software Defined Networking

We are being to enter the era of software defined networking (SDN), an emerging paradigm where network control logic (learning and forwarding decisions) is decoupled from the underlying physical network topology (routers, switches). To quote from Nick Feamster who is the Darnell-Kanal Associate Professor of Computer Science at University of Maryland: Separating a network’s control logic from the underlying physical routers and switches that forward traffic allows operators to write high-level control programs that specify the behavior of an entire network, in contrast to conventional networks, whereby network operators must codify functionality in terms of low-level device configuration. Logically centralized

Implementing strstr in Korn Shell

Neither Bash or the Korn Shell 93 (ksh93) provide a C-like strstr builtin. Here is a simple implementation of a strstr function in ksh93. The strstr function finds the first occurrence of s2 in s1. If s2 is an empty string, 0 is returned; if s2 occurs nowhere in s1, 0 is also returned; otherwise the offset to the first character of the first occurrence of s2 is returned. #!/bin/ksh function strstr { typeset s1=”$1″ typeset s2=”$2″ if [[ ${#s2} == 0 ]] then return 0 fi typeset len=${#s1} typeset first=${s1%%${s2}*}x typeset ndx=${#first} if (( ndx > len )) then

Bash Hash Builtin

The Bash shell hash builtin maintains a hash cache (table) containing the full pathname of previously executed commands that are on your PATH environmental variable. If the command is in the hash table, it just executes it without searching for it in the various path components. SYNTAX hash [-r] [-p filename] [name] OPTIONS -r Reset (causes the shell to forget all remembered locations) -p Use filename as the location of name (don’t search $PATH) If no arguments are given, information about remembered commands is printed. The return status is zero unless a name is not found or an invalid option