Information for Linux System Administration
Debugging Shell Scripts

vote
Learning how to find the errors in your shell scripts is an important skill for successful shell scripting. The debug options in the Bash shell can help with that. read more...
E-book: Perl One-Liners Explained

vote
I'm happy to announce my 3rd e-book called "Perl One-Liners Explained."
Perl one-liners are small and awesome Perl programs that fit in a single line of code and they do one thing really well. These things include changing line spacing, numbering lines, doing calculations, converting and substituting text, deleting and printing certain lines, parsing logs, editing files in-place, doing statistics, carrying out system administration tasks, updating a bunch of files at once, and many more.
Here is an example. Suppose you quickly need to generate a random, 8 character password. You can do it quickly with this Perl one-liner:
perl -le 'print map { ("a".."z")[rand 26] } 1..8'
Overall, the e-book has 111 pages and it explains 130 unique one-liners. Many of one-liners are presented in several different ways so the total number of one-liners in the book is over 200. read more...
Add Video Streaming to C/C++ apps with Nex Gen Media Server API

vote
Recently I took a closer look at Nex Gen Media Server and their API framework. NGMS is a multi-purpose streaming server which supports some of the popular streaming protocols such as RTSP, RTMP, Apple's HTTP Live, and MPEG-2 Transport Stream. NGMS comes with transcoding support and is able to capture and reformat live video streams and adapt them to be received by another type of device, such as capturing an HD video feed and converting it to be received by an iPhone over 3g. My focus was to integrate the NGMS API to control the streaming features directly from my own C application. In this example I am using Ubuntu Linux 10.04. read more...
Build Apps with Android SDK, Eclipse, PhoneGap (Ubuntu 10.10)

vote
This tutorial describes how you can set up a development environment for building Android apps on an Ubuntu 10.10 desktop using Eclipse, the Android SDK, and PhoneGap. I will describe how to build Android apps from the command line with PhoneGap and from the GUI with Eclipse and PhoneGap and how to test them in an Android emulator and on a real Android device. PhoneGap allows you to develop your Android applications using web technologies such as HTML, CSS, and JavaScript (e.g. with JavaScript libraries such as jQuery/jQTouch), and it will turn these web apps into native Android apps (in fact, PhoneGap supports multiple platforms such as Android, iPhone, Palm, Windows Mobile, Symbian, so you can use the same sources to create apps for multiple platforms). read more...
bash scripting: Looping through a list

vote
This is an example of a Bash shell script used to loop through a list to compare to text strings found in logs. The script is used to detect and block attacks on a web site. read more...
Tutorial: Android app development environment on Debian 6

vote
This tutorial describes how you can set up an development environment for building Android apps on a Debian Squeeze desktop using Eclipse, the Android SDK, and PhoneGap. I will describe how to build Android apps from the command line with PhoneGap and from the GUI with Eclipse and PhoneGap and how to test them in an Android emulator and on a real Android device. PhoneGap allows you to develop your Android applications using web technologies such as HTML, CSS, and JavaScript (e.g. with JavaScript libraries such as jQuery/jQTouch), and it will turn these web apps into native Android apps (in fact, PhoneGap supports multiple platforms such as Android, iPhone, Palm, Windows Mobile, Symbian, so you can use the same sources to create apps for multiple platforms). read more...
Up and coming programming languages

vote
Seven growing programming languages...
While the following seven niche languages offer features that can't be found in the dominant languages, many rely on the dominant languages to exist. Some run on top of the Java Virtual Machine, essentially taking advantage of the Java team's engineering. And when Microsoft built C#, it explicitly aimed to make the virtual machine open to other languages. That detail may help make deployment easier, but it doesn't matter much to the programmer at creation time.
Either way, these seven languages are quickly gaining converts in the enterprise. Perhaps it's time to start investigating their merits.
read more...
Basic awk lesson

vote
By performing these basic commands you will begin to see the power and flexibility of the Linux utility awk. This exercise is designed to start you down the path of using awk. read more...
e-book: Sed One-Liners Explained

vote
I love writing about programming and I am happy to announce my second e-book called "Sed One-Liners Explained".
Sed one-liners are short sed scripts for everyday situations in the shell, such as changing line spacing, numbering lines, and converting and deleting text.
For example, the following sed one-liner numbers the lines of a file:
sed = file | sed 'N; s/n/: /'
Here is how it works - it's made out of two sed commands. The first one uses the = command that inserts a line containing the line number before every original line in the file. Then this output gets piped to the second sed command that joins two adjacent lines with the N command. When joining lines with the N command, a newline character n is placed between them. Therefore it uses the s command to replace this newline n with a colon followed by a space ": ".
The e-book is 98 pages long and it explains exactly 100 one-liners. It's divided into the following chapters:
Preface.
1. Introduction to sed.
2. Line Spacing.
3. Line Numbering.
4. Text Conversion and Substitution.
5. Selective Printing of Certain Lines.
6. Selective Deletion of Certain Lines.
7. Special sed Applications.
Appendix A. Summary of All sed Commands.
Appendix B. Addresses and Ranges.
Appendix C. Debugging sed Scripts with sed-sed.
Index.
Did you know that sed was as powerful as any other programming language? Someone even wrote Tetris in it.
After you read the e-book, you'll be able to write your own Tetris if you wanted to. read more...
Perl One-Liners Explained: Handy Regular Expressions

vote
This is the seventh part of a nine-part article on Perl one-liners.
Perl one-liners are short programs that do one and only one task well and they fit on a single line in the shell.
Perl is not Perl without regular expressions, therefore in this part I come up with and explain various Perl regular expressions. Please see part one for the introduction of the series.
This part explains the following regular expressions:
Match something that looks like an IP address.
Test if a number is in range 0-255
Match an IP address
Check if the string looks like an email address
Check if the string is a decimal number
Check if a word appears twice in the string
Increase all numbers by one in the string
Extract HTTP User-Agent string from the HTTP headers
Match printable ASCII characters
Match text between two HTML tags
Replace all bold tags with strong tag
Extract all matches from a regular expression
read more...
Expect Script Examples

vote
Expressions, if statements, for loops, and while loops examples are covered in this mini-tutorial:
This article explains the following in the expect scripting language.
Expressions – arithmetic operation
if construct in expect
looping constructs
read more...
Tutorial: Android app build environment with Eclipse, PhoneGap (Ubuntu 11.04)

vote
This tutorial describes how you can set up an development environment for building Android apps on an Ubuntu 11.04 desktop using Eclipse, the Android SDK, and PhoneGap. I will describe how to build Android apps from the command line with PhoneGap and from the GUI with Eclipse and PhoneGap and how to test them in an Android emulator and on a real Android device. PhoneGap allows you to develop your Android applications using web technologies such as HTML, CSS, and JavaScript (e.g. with JavaScript libraries such as jQuery/jQTouch), and it will turn these web apps into native Android apps (in fact, PhoneGap supports multiple platforms such as Android, iPhone, Palm, Windows Mobile, Symbian, so you can use the same sources to create apps for multiple platforms). read more...
Bash: Use the Test Command for multiple aspects

vote
The Bash shell has a builtin test command that can be used to check for multiple aspects in a script. This exercise helps you build a script that checks to see if a file exists and if it does, checks to see if it is writable. read more...
Java: Signing and encryption with Axis2 WS-Security

vote
Get an introduction to the principles of public key cryptography, then see how WS-Security applies them for signing and encrypting SOAP messages using public-private key pairs in combination with secret keys. Includes example code using Axis2 and Rampart. read more...
Tutorial: MySQL Select statement

vote
An in-depth look at the syntax of the MySQL Select statement...
The SELECT statement is without question the most complex amongst MySQL’s data manipulation statements. Not surprising when you consider that the foremost purpose of structured query language (SQL) is to retrieve information from a relational database which adheres to a given criteria. Entire books have been written about how to construct a query to fetch the data that you’re after. That’s not the purpose of this article. Our goal will be to cover the syntax of the SELECT statement and gain an understanding of its many optional clauses. We’ll start at the beginning and work our way through them. When we’re done, you’ll understand which clauses to use for different purposes. We’ll leave the twenty table joins for another day.
read more...
perl1line.txt: A handy Perl script collection

vote
The ultimate goal of the Perl One-Liners Explained article series was to release the perl1line.txt file. Last week I finished the series and now I am happy to announce perl1line.txt - a collection of handy Perl one-liner scripts.
The perl1line.txt file contains over a hundred short Perl one-line scripts for various text processing tasks. The file processing tasks include: changing file spacing, numbering lines, doing calculations, creating strings and arrays, converting and substituting text, selective printing and deleting of certain lines and text filtering and modifications through regular expressions.
The latest version of perl1line.txt is always at:
http://www.catonmat.net/download/perl1line.txt
Enjoy! It took me over 3 years to write all the one-liners down. read more...
I wrote my first programming e-book: Awk One-Liners Explained

vote
I really love writing about programming and Linux, and I just published my first e-book ever on Awk one-liners.
Awk one-liners are short Awk programs that fit on one line and do one particular task, such as numbering lines, double spacing lines, printing only lines that match a pattern, etc.
Here is an example. The following one-liner prints all users on the Linux system:
awk -F: '{ print $1 }' /etc/passwd
This one-liner works this way. The -F: command line argument specifies that the lines in the /etc/passwd file should be split into fields by the colon character. As we all know, the information in /etc/passwd file is colon separated, so the first field $1 gets set to the username, the second field $2 gets set to the password, the third field $3 gets set to user id, etc. This one-liner prints only the first field which is the username. Simple, isn't it?
In my 50 page long e-book I carefully explain 70 one-liners in similar way.
Here is the table of contents of the e-book:
Preface.
1. Introduction to Awk One-Liners.
2. Line Spacing.
3. Numbering and Calculations.
4. Text Conversion and Substitution.
5. Selective Printing and Deleting of Certain Lines.
6. String and Array Creation.
Appendix A: Awk Special Variables.
Appendix B: Idiomatic Awk.
Index.
read more...
Python Client/Server Tutorial

vote
A tiny Python tutorial...
This application can easily be coded in Python with performance levels of thousands of transactions per second on a desktop PC. Simple sample programs for the server and client sides are listed below, with discussions following
read more...
iText: Generate PDF files with Java

vote
Many applications demand dynamic generation of PDF documents. Such applications range from banks generating customer statements for e-mail delivery to readers buying specific book chapters and receiving them in PDF format. The list is endless. This article uses the iText Java library to generate PDF documents. read more...
Vim Plugins: matchit.vim

vote
This is the third post in the article series "Vim Plugins You Should Know About". This time I am going to introduce you to a plugin called "matchit.vim".
Matchit extends the existing functionality of “%” key (percent key). I'll first briefly remind you what the original “%” does and then explain how matchit.vim enhances it. read more...
Limited Edition Abstract Art
Articles are owned by their authors. © 2000-2012 Ray Yeargin
You are viewing a mobilized version of this site...
View original page here