Posts

Showing posts from 2008

Comic - Huge Software Sale

Image
We can't have all work and no play, so a cartoon every once in a while doesn't hurt. While you're having fun, check out http://www.lifeisnojoke.com . Here are some articles on where to find free software: opensource-software-for-windows searching-for-software Now, some people may not understand that by free, we mean free. Not pirated, illegally copied, or borrowed. Open source software is free to use, copy, modify and distribute. A small to medium-sized company may have 100 computers, and have to pay $200 for some kind of office software for each machine for a total of $20,000. But if the company chooses to use free software such as openoffice , the price would be $0.00 x 100 = $0.00.

Freedom Fry — "Happy birthday to GNU"

Mr. Stephen Fry introduces you to free software, and reminds you of a very special birthday. Freedom Fry — "Happy birthday to GNU" Published on: http://www.gnu.org/fry/happy-birthday-to-gnu.html

Using the Perl Debugger Interactively

Image
Sometimes you might want to test a few ideas to implement into a perl script, but you want to see if it will work before you implement it. The Perl debugger is perfect for that. What is the Perl Debugger? Here is an intro from man perldebug : If you invoke Perl with the -d switch, your script runs under the Perl source debugger. This works like an interactive Perl environment, prompting for debugger commands that let you examine source code, set breakpoints, get stack backtraces, change the values of variables, etc. This is so convenient that you often fire up the debugger all by itself just to test out Perl constructs interactively to see what they do. For example: $ perl -d -e 42 Using the Perl Debugger Interactively To invoke the perl debugger, simply use the -d option, and give it any name, such as "1", in this example. Instead of specifying "-e 1", you could specify a filename to have perl debug the file. In this case, we wan...

How to Find Domain Names with whois_check.sh

Image
The idea to write a shell script is often the result of having to do repeated tasks. Imagine having to check hundreds of domain names by typing "whois domain.com" each time. It would take much longer than writing a simple script. Using whois to Check for Available Domain Names Suppose you want to find a good domain name, but you want to see if all of the domain suffixes are available? For example, you want a good .com domain, but you also want the .net, and .org. Not only that, but you might want to use blogspot.com, or wordpress.com for your blog. You can always check a domain availability by using the whois command, e.g. $ whois google.com Obviously, google.com is not available, so whois will display information about the company that registered the domain name. If the domain is not taken, then whois will usually return "No match", or "NOT FOUND". You have to keep trying a domain name until you find one that is available. This can be time-consumi...

Find Subnet Mask with ipcalc

An easy way to convert a subnet mask from bit notation (e.g. /24) to dotted decimal notation is to use ipcalc from any linux box. The -m option displays the subnet mask. $ ipcalc -m 10.10.10.128/25 NETMASK=255.255.255.128 $ O.K., that's fine, you say, but how do I know how many hosts are on the subnet? That's easy enough -- just use the -b option to find the broadcast address. $ ipcalc -b 10.10.10.128/25 BROADCAST=10.10.10.255 The range of IP's will be from one more than the network address up to one less than the broadcast address. In the example above the IP address range is 129-254. Often the gateway is the first or last address in the range to avoid confusion. If you don't have access to a linux box, you can always do a google search for "subnet calc," where you can probably find an online subnet calculator. For the opposite calculation - find prefix from subnet mask, use the -p option. $ ipcalc -p 10.10.10.128 255.255.255.128 PREFIX=25 $ There y...

Convert a Text File to HTML

Image
While considering how to make my shell scripts look better on the web, I started looking at freshmeat.net for programs that would convert source code to html. Then I thought, vim already has syntax highlighting. I wonder if it has a way to convert to html. Sure enough, it can be done with a single command: :runtime! syntax/2html.vim Convert Text File to HTML :runtime! syntax/2html.vim : convert txt to html :h 2html : help about 2html :wq! : write the new file The current file is converted, and an .html extension is added. Once the file is saved, it can be opened in a browser. For more vi tips, check out: http://systemnotesorg.blogspot.com/search/label/vi And the official vim site: http://www.vim.org/tips , Here is a beautiful example of C source code that was quickly converted to HTML, while preserving all of vim's color coding: http://systemnotes.org/download/matrix/matrix.c.html

Backup Logs with a Shell Script

Image
Here is a very simple way to backup and compress subdirectories. Normally you would want to copy them to a remote location in case something happens to the original drive, but in this case the concern is that disk space is filling up. Suppose you have a program that is generating log files every day, let's say they are key performance indicators (kpi) for some system that you are testing. The log files are pure text, but after a while, they take up a lot of space. One way to compress text is to use gzip, but since tar has an option (-z) to tar and gzip all at once, it may be one of the easiest solutions. #!/bin/sh # compress logs in /opt/multicast_kpi/record # by ScottM, 20080613 # Set variables TODAY = " `date +%m%d%Y` " ARCHIVE_DIR =/opt/multicast_kpi/record # move to working directory cd $ARCHIVE_DIR # For each subdirectory, make a .tgz file of it's contents, and then delete the originals. for dir in `ls -1 $ARCHIVE_DIR | grep -v " .tgz " | gre...

How to Copy Directories Using Tar

To copy all files from /usr/local/source to /usr/local/destination, there are several options. Tar cd /usr/local/source tar -cvf - . | (cd /usr/local /destination ; tar -xvf -) This method uses tar, but rather than create a file, it writes to a stream "-" in std output. The stream is piped to another tar command, after changing to another directory. cp -a cp -a /usr/local/src/* /usr/local/destination Other options: cpio dd

How to install a module from CPAN

Image
perl -MCPAN -e shell I always seem to forget this simple syntax, so I thought it would be good to post it where I can find it. Where else, my blog -- by the way, this is another excellent use for blogs. Not only do we publish information for others to find, but occasionally a blog is the best place to put frequently accessed info that the author may need. At least I know the source is reliable. :-) How do I install a module from CPAN? The easiest way is to have a module also named CPAN do it for you. This module comes with perl version 5.004 and later. To get a cpan shell, try either cpan: Linux:   $ cpan Windows:  C:\>cpan or the more complete command: $perl -MCPAN -e shell Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.7601) ReadLine support available (try 'install Bundle::CPAN') cpan> The first time the command runs, it will prompt for a series of configuration questions. Now, within the...

BCC Howto

Image
Get your Friends to use BCC Send this link, or the contents of this post, to all your contacts, ...using BCC, of course. When you receive a forwarded message, reply with a simple message, such as one or more of the following: "Please don't forward any email to me without using BCC. " "Please don't put my email address in the To or CC fields of messages being sent to people I don't know!" "Please protect email addresses as you would unlisted phone numbers." "Please don't forward any email to me with my email address in the To: or CC: fields." "This is how spam and viruses get spread. See this article for more details -- BCC HOWTO " What is BCC? BCC (Blind Carbon Copy), is the practice of sending an e-mail to multiple recipients without disclosing the complete list of recipients. Unlike addresses in the To: or CC: fields, addresses in the BCC: field cannot be seen by other recipients. Reasons to use B...

Sudo Make me a Sandwich

Image
You may have seen this artwork around the office where Unix / Linux geeks hang out. This is where you can find it: http://xkcd.com/149/ Powered by ScribeFire .

Notes from Ubuntu 7.10 Live CD

Image
Every once in a while, I like to try a few live CD's to see how the distros are progressing. I am happy to report that Ubuntu is getting more usable with each release. I titled this "Notes from..", rather than "Notes about", because I was able to work within a live CD session, and save my files. I admit I wasn't very impressed with the first version of Ubuntu I looked at. That was version 4.1, which I got in live CD format from a local linux user group meeting. After realizing that I couldn't read my NTFS partitions, I played a few games, and quickly lost interest. Also, I had a slower laptop at the time, and having the os frequently read from the CDROM made the experience slightly annoying. Now with a faster CDROM drive, and all the updates, the system is quite pleasant to use. Getting Started Using a boot CD is quite easy, and does not require anything to be installed to the hard drive. The entire operating system can be booted from a CD, and run...

Simple cdrecord Wrapper Script

Image
This little shell script is a good example of how to simplify a task with a wrapper script. Rather than trying to remember which settings to use for cdrecord, I just run my cdroast.sh script. ----- begin script ----- #!/bin/sh # cdroast.sh # scottm, 2005-07-20 # wrapper for cdrecord INPUT = $1 if [ $INPUT ] then cdrecord -v -sao dev = 0 , 0 , 0 $INPUT else printf " \n Enter name of file \n " printf " e.g. $0 filename.iso \n\n " fi ----- end script ----- Now, with the script in my path, all I have to type is: $ cdroast.sh myfile.iso and the burn process will start. This type of script is often called a wrapper, since it wraps a simple script around a more complicated procedure.