Recently in Tech Category

Changing the length of the Basename in Movable Type's settings will change the Basename length for new entries. The Basename for existing entries will not change.

I tried using Brad Choate's EntrySetBasename plugin (which was written for MT4.x) to change the Basename for all existing entries, but the plugin would not install without an error in the Movable Type 5 admin interface - and MT would not work with the plugin installed.

I wanted all blog entries to have up to the maximum of 250 characters for the Basename length, and I was willing to delete, if necessary, all entries (about 775) and import them with new Basenames. So, these are the steps I took (I am not responsible for any problems you may encounter. Backup all files first.):

  1. Export all blog entries to a backup file (important in case you mess up)
  2. Back up the source blog to a backup file (same reason)
  3. Create an index template in the format used for MT entry export files
  4. Change the Basename field in the template to the EntryTItle but with hyphens removed and dirify-ed with spaces changed to underscores
    • change:
    • to:
      BASENAME: <$mt:EntryTitle regex_replace="/-/g","" dirify="_" trim_to="250"$>
  5. Set an Output File for the template
  6. Publish the template to generate the output file (which is an export file of all entries with a maximum 250-character Basename)
  7. Copy the output file into the mt/import/ directory
  8. Delete all entries from the blog
  9. Import the output file that is now in the mt/import directory
  10. After the import finished, remove the output file from the mt/import directory (important so you don't import the entries again by mistake)
  11. Check to make sure entries with long EntryTitles also have long Basenames - and they do!

The export template format I used is below.

Another note to myself and others who may not know this…

If your MT installation is in one domain, but your blog or website is in a different domain (on the same server) - and the mt-static directory is located outside the MT installation, the stylesheet included with an MT theme won't work unless you set the StaticWebPath in the mt-config.cgi file to include the full URL where the MT installation is located.

So, in the mt-config.cgi file, you need to change:

StaticWebPath  /mt-static/



Go to the MT Documentation page about StaticWebPath.

Another note to myself and others who may not know this…

Changing Settings > General> Archive Settings > File Extension to "php" does not change the extension for the "Main Index" index template. Check other templates to ensure the extension on the Output File setting is what you want.

To change the Main Index file extenion to "php", you must manually change that template's Output File from "index.html" to "index.php".

A note to myself and others who may not know this…

If your MT installation is in one domain, but your blog or website is in a different domain (on the same server), MT's Search Widget and Tag Search (the link on the tag names) won't work unless you set the CGIPath in the mt-config.cgi file to include the full URL where the MT installation is located.

So, in the mt-config.cgi file, you need to change:

CGIPath /cgi-bin/mt/



Go to the MT Documentation page about CGIPath.

Use sed to change multiple filenames

| 1 Comment

I wanted to replace all hyphens in all filenames starting with 2003- and ending with .php. Here's how I did it using sed (no guarantees, no warranties, use at your own risk!):

  1. Backup the files!
  2. Change to the directory you want to make the changes in.
  3. Then, to make sure the right filenames will be changed, list the filenames using the following sed command (modify "2003-*.php" and the sed search and replace strings for your situation):

    for filename in 2003-*.php; do echo $filename | sed \e 's/\-/\_/g'; done

  4. When you're sure the above sed command is listing the right filenames, change it as follows (modify "2003-*.php" and the sed search and replace strings for your situation):

    for filename in 2003-*.php; do newname=`echo $filename | sed \e 's/\-/\_/g'`; mv $filename $newname; done

Note the use of the backtick character (`) (also known as backquote) which, on my keyboard, is located to the left of the "1" key. The backtick character is used in addition to the single quote character (').

[Update January 4, 2009] I totally forgot that I could have used the "rename" command instead of sed! There is control over which underscore in a filename is changed. More about renaming files using "rename".

Finally backed up my PC

| No Comments

I bought an external hard drive in December 2007 so I could backup my PC. Of course, the box containing the drive stayed unopened on the floor of my home office until this past Saturday - yes, 7 months of having but not using a backup system!

I bought a Western Digital WDG1T7500N My Book Pro Edition 750 GB from Amazon for $283 - the price is now $329.99. Using the Retrospect backup software that came with the drive, I setup an automatic daily backup running at 12:00am each evening which I may change because the backup doesn't run when the PC is in standby mode.

I tested a restore and it worked great!

Dead phone

| No Comments

I committed a technical support faux pas at work yesterday. I moved my phone from one side of my desk to the other and then it no longer worked. No sound. I checked the connector to the wall - ok. No sound. I pulled the connector out of the wall port and re-connected it. No sound. I checked the volume control - ok. No sound. I turned over the phone to make sure the cable was secure - ok. I placed a helpdesk request: "my phone is DEAD".

The phone guy from IT visited today mid-morning…

Use rename to change multiple filenames

| 1 Comment

I {heart} UNIX! In addition to the 'find' commend, I just found another very useful command that is now my second favorite!


The rename command renames files according to a pattern, such as:

I needed to rename almost 800 files from a format like "2007_XXXXXXXXXXXXXX.php" to use a hyphen (dash) instead of the underscore after the year - such as "2007-XXXXXXXXXXXXXX.php". I did this with the following for each year (there's probably a way to rename all years at once, but I didn't have a backup and didn't want to screw it up):

rename 2007_ 2007- 2007*.php

which means "change the string 2007_ to 2007- in all filenames resulting from 2007*.php".

Worked like a charm!!!

I am not responsible for any problems you may encounter. Backup all files first.

I started working for my current employer as their Web Designer almost 6 years ago. I worked with one of the System Administrators to setup a new web server environment and processes. She built two SuSE UNIX servers (one for development, the other for "live" published websites), installed the Zope web content management system, and used Apache to handle the website. She kept all access to root and managed the hardware and software on the servers - even today, I don't know where they live on campus!

When she left about 2 years ago, one of the other System Administrator's inherited management of "my" web servers. Soon, however, he agreed to give me root access so he wouldn't have to change file/directory permissions for user directories, add Rewrite commands to the httpd.conf file, modifying other config files (ht://dig, Webalizer, etc.), manage large files when the Zope database needs to be packed, and do other administrative tasks on the web servers that took him away from bigger projects. That was okay with me! I'm comfortable at the UNIX command line and am perfectly capable of doing those tasks.

When the servers were setup, directory browsing was turned off on the server for better overall security. A year or so later, one user wanted to be able to list the files in a single website directory, but the System Administrator wasn't able to set httpd.conf so that it worked. Then, about 2 years ago, another user (a more demanding one) wanted to do the same thing with a bunch of his Camtasia files. The one remaining System Administrator at that time was a Microsoft Windows only guy so nothing could be done. I learned a bit about httpd configuration commands but was unsuccessful in getting "Options Indexes" to work. So, I wrote a PHP script to be placed in a directory as index.php. When that file is accessed in a browser, it displays the foldernames and filenames contained in that directory and its subdirectories. It worked great!

But it's always bugged me that directory browsing wouldn't work on the servers! Well, today I spent most of my work day Googling away for anything that could help (such as (no quotes) "disable directory browsing", "enable directory browsing", "enable directory browsing for one directory", "suse apache directory browsing") and making modifications to the httpd.conf file on the development server. I must have restarted Apache 50 times or more!

I learned what the httpd configuration commands do (important!). I discovered Include statements in the httpd.conf that included *.conf files for SuSE, and thought maybe I had finally found where the problem might be. No luck.

About 30 minutes before the end of the day, I Googled "directory browsing not working" (no quotes) and found this thread on a forum that pointed me to, ta da, the solution!

From Ddr/Dale's response post:

IndexIgnore *

(will prevent listing of all files, the "*" is a wildcard)
IndexIgnore *.gif *.jpg

(will prevent listing of any files with .gif or .jpg extensions, but will allow other listings)

Could it be? Was there an "IndexIgnore *" command in the httpd.conf file?

Yes. Yes, indeed. It was there, bold and bright as day, jumping from the screen saying "I'm here, I'm here!" (now that I knew what it meant)!

So, I removed it. And all was fine with the world again. Well, maybe just my little corner of the world.


  • To disable directory browsing, use "Options -Indexes" or remove "Indexes" from an "Options" command (i.e., "Options Indexes FollowSymLinks" becomes "Options FollowSymLinks").
  • To enable directory browsing, use "Options +Indexes" or add "Indexes" to an "Options" command (i.e., "Options FollowSymLinks" becomes "Options Indexes FollowSymLinks"). Make sure "AllowOverride Options" is included in the httpd.conf file in a <Directory> section for the directory where the DocumentRoot is.
  • Do not use "IndexIgnore *" to disable directory browsing. It is used to disable display of certain folders/files - not all folders/files - while directory browsing.

Now I feel I must address why I am a former UNIX System Administrator with 10+ years experience and have not worked with Apache configuration!

Way back before Windows 3.1, my employer used UNIX servers with terminals (we referred to them as dumb terminals because they had no processing capabilities - they just displayed what was delivered to them from the UNIX main frame computer).

I was the System Administrator for the UNIX systems. Again, that was before Windows 3.1 - and before the World Wide Web became widely used with the help of GUI web browsers.

Anyway… I was the System Administrator for those 8 or 9 systems. As such, I created UNIX user accounts, configured software (including UNIX-based WordPerfect!), wrote shell scripts, troubleshooted problems, created/managed Informix databases, wrote programs to interface with the databases, considered the vi editor and the "find" command my best friends. And more. Even after the WWW became popular, my employer didn't have a website until, I think, 1997 or 1998, but I had already left that employer in May 1996. But that's not the point here…

The point is: Although I was a UNIX System Administrator until 1996, I have never been the administrator for a UNIX-based web server (such as Apache)! Sure, I've played around with my own web hosting accounts on UNIX servers using the Apache web server since 1998 (maybe earlier?), but I haven't gotten into the nitty gritty of how Apache works.

Until today!

I wanted to change "/artscrafts/" to "/blog/" in all popup image files (these are not stored in the MT database so search-and-replace inside the Movable Type 4.01 administrative interface doesn't work for those files). The file for each popup image is stored in the same directory as the popup image.

The following worked for me, but there is no guarantee that it will work for you. I am not responsible for any problems you may encounter. Backup all files first.

To change a string of characters to a different string of characters in multiple files:

  1. At a Unix prompt, cd to directory where the files to be modified are located
  2. Type on one line: for f in *php; do sed 's/string1/string2/g' $f > $ && mv $ $f; done

Line 2 means: For every file ending with php, replace string1 with string2 and save the result into a new file, then move the new file over the original file.

For each slash in the string, I needed to use \ in front of it, as follows:

for f in *php; do sed 's/\/artscrafts\//\/blog\//g' $f > $ && mv $ $f; done

Multiple lines can also be used at a Unix prompt as follows:

for f in *php
sed 's/string1/string2/g' $f > $ &&
mv $ $f

Based on information in a thread at dBforums. Note: That code uses the Unix find command to locate files which could be in subdirectories. Back up all files and learn about the find command before using.

for fname in $(find . -name "*" -print)
sed '/word/s/word/new_word/g' ${fname} > ${fname}.new &&
mv ${fname}.new ${fname}

Sketch of Cheryl

About Cheryl

Enjoys crocheting, gardening, cats, NASCAR (especially Tony Stewart and Kyle Busch!), reading, photography, snorkeling in Kailua-Kona with sea turtles, Sizzler's Mega Bacon Cheeseburgers, hot and iced decaf coffee, dark chocolate, color (yarn, fabric), playing around with web technologies - not necessarily in that order! Still very much a beginner with quilting, knitting, and sewing. Donates crocheted lap blankets.

List maker, detail-oriented, organized, leans heavily toward perfectionism. ISTJ. Libra.

January 2017

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Disclaimer: This is a personal website - my place of self expression. The views expressed are mine alone and do not necessarily reflect the views of my employer or any other organization I am a member of or affiliated with.
Creative Commons License
This blog is licensed under a Creative Commons License.
Powered by Movable Type 5.2.2

About this Archive

This page is an archive of recent entries in the Tech category.

Socks Projects-Crochet is the previous category.

This Site is the next category.

Find recent content on the main index or look in the archives to find all content.

Cat playing with strand of yarn.


Recent Comments

  • debbbie30612: Thanks Cheryl I had a swatch of this pattern many read more
  • adam.primecp: Love this! I work with AllFreeCrochet and have been trying read more
  • Hello... I am looking for a Cheryl Lambert that is read more
  • Please please also let me know how to contact read more
  • ancyvan66: I am working on one of these right now. I read more
  • joebrazauskas: Cheryl, I really meant to respond on your page about read more
  • Hi, just came across your blog today and wanted to read more
  • jeaninkpr: Thanks so much - this is exactly what I was read more
  • Marion Vanstone: Hi Cheryl I received an email from Katherine Keselowsky (aka read more
  • Sandra: 'A Dozen & One Tunisian Dishcloths' by Annie's Attic I read more