Translate

Image of Linux Kernel Development (3rd Edition)
Image of Android Wireless Application Development
Image of Operating System Concepts
Image of Beginning Google Maps API 3

Korn Shell Ordinal Number Conversion

It is useful to be able to convert to and from ASCII ordinal numbers in scripts. Here is one way of doing it in Korn shell scripts. To convert the character ‘F’ to it’s ASCII ordinal value: $ print $((‘F’)) 70 To display the ASCII character associated with the ordinal number 70: $ typeset -i8 c=70 $ printf “\${c#*#}n” F

Bash XOR A String

Here is an example of how to XOR a string variable using the Bash shell. Each character in the plaintext string is XOR’ed with decimal 90. #!/usr/local/bin/bash plaintext="abcdefg" echo "Plaintext: $plaintext" cyphertext="" for ((i=0; i < ${#plaintext}; i++ )) do ord=$(printf "%d" "’${plaintext:$i:1}") tmp=$(printf \$(printf ‘%03o’ $((ord ^ 90)) )) ciphertext="${ciphertext}${tmp}" done echo "Ciphertext: $ciphertext" # now XOR again and we should get the original string back plaintext="" for ((i=0; i < ${#ciphertext}; i++ )) do ord=$(printf "%d" "’${ciphertext:$i:1}") tmp=$(printf \$(printf ‘%03o’ $((ord ^ 90)) )) plaintext="${plaintext}${tmp}" done echo "Plaintext: $plaintext" The key lines are the ord= and the tmp=

Porting KSH93 to Windows 7 SUA

This post shows you how to download, build and install the latest version of the Korn shell in the Windows 7 SUA subsystem.

Korn Shell 93 Hash Builtins

This post shows you how to incorporate hash functions built into the AT&T Advanced Software Technologies (AST) libsum library in your Korn shell shell scripts via custom builtins in a dynamically loadable plugin.

Using Types To Create Object Orientated Korn Shell 93 Scripts

This post discusses the concept of types which are a recent addition to ksh93 and, by means of a number of examples, demonstrates how to use types to implement an object-orientated approach to writing ksh93 shell scripts.