HOW-TOs

Tech Tip: Really Simple HTTP Server with Python

If you need a quick web server running and you don't want to mess with setting up apache or something similar, then Python can help. Python comes with a simple builtin HTTP server. With the help of this little HTTP server you can turn any directory in your system into your web server directory. The only thing you need to have installed is Python.

Use curl to Monitor Your Vonage Phone Bill

If you're a Vonage user and you'd like to keep tabs on your bill as the month progresses, the script described here can help. The script uses curl to login to your Vonage account and download the web page with your current balance. The balance is then extracted using grep and sed.

Returning Values from Bash Functions

Bash functions, unlike functions in most programming languages do not allow you to return a value to the caller. When a bash function ends its return value is its status: zero for success, non-zero for failure. To return values, you can set a global variable with the result, or use command substitution, or you can pass in the name of a variable to use as the result variable. The examples below describe these different mechanisms.

Tech Tip: Port Forwarding in Virtualbox with VBoxManage

VirtualBox is a free, powerful and versatile virtualization program which is available for Linux, Mac, and Windows hosts, and can virtualize many different Operating Systems. VirtualBox was originally developed by Innotek, but was purchased by Sun and renamed Sun xVM VirtualBox.

Normalizing Path Names with Bash

The bash function presented here normalizes path names. By normalize I mean it removes unneeded /./ and ../dir sequences. For example, ../d1/./d2/../f1 normalized would be ../d1/f1.

Accessing SQLite in C

In my last article I wrote about accessing a PostgreSQL database in C/C++. In this article, I'm going to discuss performing the same functions in C against an SQLite database. Unlike Postgresql and the supporting libraries, SQLite creates completely self-contained databases that aren't dependant upon a client-server architecture.

Bash Quoting

Quoting things in bash is quite simple... until it isn't. I've written scripts where I'd swear 90% of the effort was getting bash to quote things correctly.

Tech Tip: More ssh Tunneling

Using ssh tunnelling I can protect services which are not normally protected and/or encrypted against unauthorized access. In this example I show how I set up a secure connection to my IRC proxy, but you can use this same recipe for other things.

Reading Multiple Files with Bash

Reading files is no big deal with bash: you just redirect the input to the script or pipe the output of another command into the script, or you could do it inside the script if the file names are pre-determined. You could also use process substitution to pass in the open files (command pipelines actually) from the command line. Another option, the one I describe here, is to just open the files and read (or write) them as you like, as you'd do in other programming languages.

More Debt Watching from the Command Line

Those of you who watch our Tech Tip Videos may have seen my video on how to fetch the US National Debt at the command line. The script contained here uses the idea I developed there and expands it to fetch the debt twice, with an optional pause in between, and then display the amount that the debt has increased during the pause.

Tech Tip: Removing Unnecessary Packages on Debian Systems

The command deborphan can be used to check for unnecessary (orphaned) packages. By default deborphan searches for orphaned libraries, but you can have it search for other types of packages also: data packages, dev packages, etc. by specifying one of its many --guess-* command line options.

OpenOffice.org: Cross-References Revisited

Four years ago, I wrote an article about OpenOffice.org writer called "Fielding Questions, Part 2 - Cross References and User-Defined Fields." I regularly receive mail about it, but these days I have to preface each reply by explaining that the article is obsolete. Repeating the explanation gets old quickly, so I decided that an update is necessary.

Tech Tip: View Config Files Without Comments

I've been using this grep invocation for years to trim comments out of config files. Comments are great but can get in your way if you just want to see the currently running configuration. I've found files hundreds of lines long which had fewer than ten active configuration lines, it's really hard to get an overview of what's going on when you have to wade through hundreds of lines of comments.

Accessing PostgreSQL in C/C++

For some, databases can be pretty intimidating. I remember some of the convoluted code I wrote years ago in order to avoid having to learn how to access a database from my programs. But it's actually not that hard to access a database, even in C/C++.

Capturing Video (How I Did It)

One of the common questions we get here at linuxjournal.com is how we produce our videos. Shawn produced a howto video on some ways of doing it. The following describes how I capture my videos and also the script that I use to add the Linux Journal logo watermark to it.