Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Tony Lawrence

Company: AP Lawrence

Tutorials written by Tony Lawrence:

BackupEDGE 2.1
The latest version of Microlite BackupEDGE adds several new features. For those who are not familiar with the product at all, a quick recap is in order:
Tuesday, 3rd May 2005

Bash 3.00 brace expansion
Ah, finally: no more of for i in 1 2 3 4 5 6 7 8 9 0 do .. whatever done
Tuesday, 4th October 2005

Bash Aliases
Most shells have some provision for aliases. Aliases can assign default behavior to a command (for example "rm" is often aliased to "rm -i") or can be used to create new commands (a typical example is "ll" aliased to be "ls -l").
Friday, 2nd September 2005

Bit Vector, Using Perl Vec
A bit vector is just an array of bits; subsets of bits within the bytes have some meaning. That allows more compact storage for certain types of data. For example, if you only needed boolean on-off values, you can store eight values in one byte.
Tuesday, 19th July 2005

Blacklist Unwanted IP Addresses
On Linux, it's easy enough to add an iptables rule to blacklist a particular ip address. You can even automate the process based on certain criteria that you define. However, you don't necessarily want to leave an ip blacklisted forever, because it may be transient (a legitimate user may have that ip address tomorrow), or the condition that triggered your block may have been an error. The ip address may even have been spoofed, thus denying access to legitimate users.
Tuesday, 3rd May 2005

Control Your Domain Registration Data
Your domain registration is critically important. It's easy to get lazy about this stuff. Often your ISP or whoever set up your web site said they'd "take care of it" and that was it. It's been working fine for years, and you don't have to worry about it.
Monday, 29th August 2005

Controlling Core Files (Linux)
If you don't want core files at all, set "ulimit -c 0" in your startup files. That's the default on many systems; in /etc/profile you may find
Thursday, 12th May 2005

Creating Perl Modules for Web Sites
When you are writing your own code, you are more apt to use someone else's module than write your own, unless your project gets fairly large and complex. Small scripting tasks just don't need the advantages modules offer.
Tuesday, 19th July 2005

Creating Perl Modules for Websites
When you are writing your own code, you are more apt to use someone else's module than write your own, unless your project gets fairly large and complex. Small scripting tasks just don't need the advantages modules offer. However, there is a case where modules might make perfect sense: web server cgi scripts often repeat the same tasks.
Thursday, 16th June 2005

Enabling Linux Telnet
This has to be one of the more common support calls that I get. The telnet daemon is no longer usually installed by default, so people are surprised when their newly installed Linux system won't answer telnets.
Wednesday, 8th March 2006

Fork and Exec with Perl
Recently I had a project that required a number of different programs that will mostly run all the time, but need to be restarted now and then with different parameters. Normally, the first thing I think of for a program that runs constantly is inittab or svc (daemontools). The svc facility is the more flexible of the two, and will be what I'll use in the final design, but in the "thinking" stages I played with using a Perl program launcher and controller. What we have is a config file that specifies programs
Wednesday, 27th April 2005

Goal Seeking Code
This is an extremely unsophisticated program that demonstrates evolutionary DNA. You start by passing it a string:
Tuesday, 3rd May 2005

Google Sitemaps
Google is now letting web sites submit an xml file that lists urls and some information about how often the pages change, and how important the page is relative to other pages. Basically, it gets you to do part of the work for them - which we would hope helps everyone.
Thursday, 16th June 2005

Handling Missing Data in Inputs
Missing data can be very annoying to a programmer. In fact, it is so annoying that very often we'll write separate programs to clean up data and eliminate unpleasant conditions so that the main program doesn't have to deal with it. Here, I'll show some examples of the kind of problems we see.
Tuesday, 3rd May 2005

Hardening your Kernel with OpenWall
The Openwall Project provides security related kernel patches for Linux and BSD kernels. I read about this in Hardening Linux by James Turnbull. The patch that most interested me was to prevent executable code from running in the stack. That won't prevent all buffer overflow attacks, but it can stop some of them. I really don't understand why this isn't just the default nowadays - I know it can break some programs and debuggers, but it seems smart to me
Thursday, 12th May 2005

How Can I Mount a ISO Image CD?
You have an image of a CD or perhaps of a floppy disk. You may have downloaded it, or created it by reading a real device with "dd". Now you want to mount that image. You could write it back out to media and mount that, but that may not be convenient or even possible at the moment.
Wednesday, 11th May 2005

HTML Forms POST, GET
Web forms have two possible methods of passing information back to the script that will process the form. Every form will have something like this...
Sunday, 21st August 2005

Javascript setTimeout Problem
A neighbor wanted to run Google ads on his website. It's one of these turnkey things that give you an on-line store that you can add products to. It's all PHP and Javascript driven, but it wasn't too hard to find a place to stick the Google code (which is also Javascript).
Monday, 25th April 2005

Loadkeys, Dumpkeys
You can change the output of the console keyboard with loadkeys. It's an extremely powerful command, and the man page can be confusing, but for simple use (which is often all we need it for), it's very easy.
Wednesday, 18th May 2005

Loglevel
Syslog is a wonderful thing. In theory, it lets an administrator fully control where and how messages get logged. Of course, the first requirement is that the program you wish to control uses syslog for logging, but even assuming that it does, it can still be difficult to get what you want.
Friday, 13th May 2005

Lost Root Password (Linux)
I have a very good memory. I remember most of my client's passwords (there are a few I forget regularly for no reason that I can understand, but I really do know most), I remember telephone numbers, and of course I know my own passwords. That last isn't as easy as it might sound, because I have quite a few different systems and each has its own password, but though I might use the wrong one now and then, I'll get it on the second or third try.
Wednesday, 11th May 2005

Lost Root Password - Linux
Have you ever forgotten your root password? I have a very good memory. I remember most of my client's passwords (there are a few I forget regularly for no reason that I can understand, but I really do know most), I remember telephone numbers, and of course I know my own passwords.
Thursday, 13th April 2006

Magic Sysrq
The Magic Sysrequest Key is Alt (left or right Alt key) and Sysrq (up there under Print Screen, next to F12 on most keyboards). To use it, you need to have it enabled in your kernel (CONFIG_MAGIC_SYSRQ). It usually is; if you have a file called '/proc/sys/kernel/sysrq' you have this. To ENABLE the magic functions, you need a 1 in that file. If it has 0, Alt-SysRq just returns you to the previous console you were using.
Tuesday, 3rd May 2005

Mound --Bind
Most Linux and Unix file systems don't allow hard links to directories (except for the . and .. entries that mkdir creates itself). The reasons are are pretty obvious: you could really confuse programs like ls (ls -R), find and of course fsck if you created links that recursed back to themselves.
Saturday, 29th April 2006

PATH, Command
Your PATH (echo $PATH) is where your shell will search for executables. If a command you want to run isn't included in $PATH, you have to be specific: /somewhere/someprog. One confusion for Unix/Linux newcomers is that if PATH doesn't include "." (current directory), then trying to run a program you can see right in front of your nose with "ls" is going to generate a "command not found" message from your shell.
Friday, 13th May 2005

Perl binding, or vs. ||
Perl has "||" and "or". While "or" can't be used in bit operations, either one can be used in logical flow control - but there is an important difference between them.
Thursday, 16th June 2005

Perl Getopt and GetOptions
Two Perl modules (Getopt and Getoptions::Long) work to extract program flags and arguments much like Getopt and Getopts do for shell programming. The Perl modules, especially GetOptions::Long, are much more powerful and flexible.
Friday, 22nd April 2005

Perl Input
Perl has wonderful I/O capabilities. I'm only going to cover input here: reading from files or standard input. There are two ways to do that (actually a lot more than two, but this is supposed to be introductory material): you can open a specific file, or you can pass files on the command line and either open them individually or just ignore the whole thing and pretend everything is coming from STDIN.
Monday, 25th April 2005

Perl Net::FTP
Before the wide spread availability of Perl, I would script ftp transfers with .netrc, ksh scripts and other clumsy ways. None of those methods are fun, flexible or easy. On the other hand, Perl's Net::FTP module is all of that.
Wednesday, 27th April 2005

Perl Range Operator
In a list context, this operator is easy to use and understand. It is much more confusing in a scalar context, and is often badly explained in books and webpages.
Thursday, 16th June 2005

Perl Sorting
Arrays often need sorting. Perl has built-in ways to help you, but as usual, there's more than one way to do it. To play with the examples shown here, you'll need a file containing a few lines of words.
Monday, 25th April 2005

ps sorting
In the beginning, when large creatures lumbered through damp tropical forests and furry mammals hid quivering in their burrows, "ps" had no built in abilty to change its sort order. You got what it gave, and if you wanted it otherwise, you ran it through "sort" yourself. That is the Unix Way: small tools, working together with pipelines.
Friday, 2nd September 2005

Python vs. Perl
I went to http://www.python.org/doc/current/index.html and used the excellent tutorial there. I found things to like and things to dislike immediately:
Monday, 25th April 2005

Random subroutines in Perl
I'll bet your first question might be "why on earth would I ever want to call subroutines randomly?". Admittedly, it isn't a need that comes up that often, but (for example) it's used right here on this very page that you are reading.
Friday, 23rd November 2007

Replacing a Spreadsheet
Spreadsheets can be powerful tools, and particularly so in the hands of an expert user. A spreadsheet can be used to reorganize data and to extract information not otherwise available. For example, at a client site, an application report generates a listing of hourly billing, but can't give the cross-reference totals desired. The raw output looks something like this:
Tuesday, 3rd May 2005

SMB Caching
A customer had a particular shared folder setup so that only he had access to it. This happened to be a SCO Visionfs system, but you could run into similar problems with Samba.
Thursday, 1st June 2006

Symlinks
Linux "symlinks" is a handy utility for managing symbolic links. It can clean up the sort of problems that come from carelesness when creating symbolic links.
Wednesday, 19th October 2005

sysfs
Linux 2.6 introduces the /sys filesystem which you will notice in "mount" output:
Tuesday, 3rd May 2005

Tar Wild Card Interpretation
I had this email earlier this week:I am trying to restore a file "\GL050". I can see it on the tape listing, but I can't get edge to find it. I have tried listing it the following ways:
Sunday, 23rd April 2006

Text Configuration Files and XML
Configuration files are a problem for both operating systems and applications. Where do you keep them, how are they structured? Traditionally, Unix systems used text files with wildly varying internal structures, and Windows used either binary data or ".ini" text files (in this sense, "binary" is used for anything that you can't access directly with a simple text editor). More recently, Windows abandoned .ini files in favor of a binary central registry.
Monday, 25th April 2005

Text::Autoformat: Smart Text Reformatting with Perl
I've been using http://groups-beta.google.com/ for Newsgroup posting for a while now. It's convenient for me because of my nomadic life style where I have different ISP's and often different machines with varying OSes. Google only needs a browser, and they aren't overly fussy about that, either.
Tuesday, 3rd May 2005

Transferring Mail to a New Mail Server
Sometimes we just have to move on. Your current mail server may just not be meeting your needs, so you've put up something new. But what about old mail? If your servers are identical (Sendmail to Sendmail, etc.) or use the same mailbox storage format, you may be able to just transfer files directly. If not, read on..
Tuesday, 3rd May 2005

Understanding Floating Point Formats
Under ordinary circumstances, you don't have to know or care how numbers are represented within your programs. However, when you are transferring data files that contain numbers, you will have to convert if the storage formats are not identical.
Tuesday, 21st October 2003

Undoing Bad Archives
Most zip or tar archives are made so that they unpack into a sub-directory. However, every now and then you run into one that wasn't done that way, and if you happen to unpack it in a directory that already has files, you end up with confusion: what was just unpacked and what was already here?
Wednesday, 19th October 2005

Using Sudo
Most Unix systems have some way of letting ordinary users perform certain tasks as root or some other privileged user. SCO Open Server has "asroot" and can also directly assign "authorizations" such as backup privileges or being able to change other user's passwords. SCO Unixware/Open Unix 8 have a similar facility in "tfadmin". Many Unixes, and Linux, use "sudo".
Thursday, 12th May 2005

Web Log Analysis
There are many tools available to analyze web page statistics. One of the most popular is Analog, but any web search will turn up hundreds or perhaps even thousands more. There are also options like Hitbox which provides statistics gained through code included in your web pages.
Saturday, 30th April 2005

Writing and Compiling C programs on Linux
Most Linux and Unix programs are written in C. When you download source for a project, it will often be C or C++ source code. You don't necessarily need to know a darn thing about C or anything else to compile the source if you aren't changing it. It may be helpful for you to understand a bit if you are having problems with the compile, but even that isn't really necessary.
Friday, 22nd April 2005

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources