Getting the error ‘cannot move – to a subdirectory of itself’?

This error message always bothered me because it makes no sense when I get it.

Here’s my scenario… I have a directory that is used as the base for all new accounts I sell on my servers. The path is; /root/cpanel3-skel. I always put WordPress in that directory and I want to keep the latest version of WP in that directory

[root@wiredtree ~]# rm -r wordpress latest.*
rm: cannot remove `wordpress’: No such file or directory
rm: cannot remove `latest.*’: No such file or directory
[root@wiredtree ~]# wget -q http://wordpress.org/latest.zip
[root@wiredtree ~]# unzip -q latest.zip
[root@wiredtree ~]# mv -f wordpress/* /root/cpanel3-skel/public_html/
mv: cannot move `wordpress/wp-admin’ to a subdirectory of itself, `/root/cpanel3-skel/public_html/wp-admin’
mv: cannot move `wordpress/wp-content’ to a subdirectory of itself, `/root/cpanel3-skel/public_html/wp-content’
mv: cannot move `wordpress/wp-includes’ to a subdirectory of itself, `/root/cpanel3-skel/public_html/wp-includes’

WHAAAAT? Obviously it is not a subdirectory of itself…

Something strange is going on… We get a little more information if we try to do a move from one device to another. Take a look at this error message:

[root@wiredtree tmp]# mv -f wordpress/* /root/cpanel3-skel/public_html/
mv: inter-device move failed: `wordpress/wp-admin’ to `/root/cpanel3-skel/public_html/wp-admin’; unable to remove target: Is a directory
mv: inter-device move failed: `wordpress/wp-content’ to `/root/cpanel3-skel/public_html/wp-content’; unable to remove target: Is a directory
mv: inter-device move failed: `wordpress/wp-includes’ to `/root/cpanel3-skel/public_html/wp-includes’; unable to remove target: Is a directory

This reveals the true source of the error message. In “mv –help”, the explanation of “-f” is too simplified and says only:

-f, –force do not prompt before overwriting

In “cp –h” we closer,but not exact, explanation of the real process, and one that better matches the inter-device error message:

-f, –force if an existing destination file cannot be opened, remove it and try again

The final bit of information is in an Ubunto bug 71174 “Misleading error message with mv and existing directories” where they change the error message to be “mv: cannot move `a’ to `b/a’: Directory not empty”.

So there you have it. You get that error message because the -f command tries first to remove the directory and can’t because it contains one or more files. You don’t get this message if the subdirectories are empty. The remove works fine on an empty directory but fails if there are files. The Linux core can’t correctly handle this exception and throws up what is probably the last error message in a switch/case statement “cannot move – to a subdirectory of itself”.

So what do you do about it? Well you can either empty the destination directory first, or you can copy the files and then delete the source directory. I chose the latter option and run this from the root folder:

rm -r wordpress latest.*
wget -q http://wordpress.org/latest.zip
unzip -q latest.zip
cp -rf wordpress/* cpanel3-skel/public_html/
rm -r wordpress latest.*

Cool? Hope that helps someone…

Jeremy Wright sets sail to uncharted waters

Jeremy Wright publicly announced today that he has has left the helm of b5media.

My family owes a lot to Jeremy Wright. With Aaron Brazell, Jeremy brought me into b5media, full time in this world of new media.

I’d not have made many of the friends I have today or traveled to some of the places I’ve been, without Jeremy and his dream for b5. He’s a good friend and a good man.

Times have not always been easy, but Jeremy has had the courage to make the difficult decisions that allowed my family and many others to still put food on the table. This is only due to Jeremy’s leadership and the strength of those at b5’s helm. Other companies in our market space have not been fortunate enough to have the same caliber of leadership.

Thank you for all the hard work over the years Jeremy, from all of us.

How do you get the current directory name in PHP?

I ran into a situation where I wanted to get the name of the directory I was in, in PHP. To be clear, I didn’t want the full path, just the directory/folder name

To be clear, if I was working in the directory:
/home/username/public_html/addonname

I wanted to have addonname returned.

I worked out two solutions.

The first solution used the getcwd() function which returns the full directory path as shown above but to use the basename function to get the part I needed. It worked so… “echo basename(getcwd());” returns “addonname” in this scenario.

That would meet my needs perfectly. I believe that matches my requirements in spirit, but was not literally correct. That statement returned the current working directory, but not the directory where the file was located. In fact, PHP 4 and PHP 5 differ when getcwd() is called from the command line. If you are in the ‘/’ directory and execute “php /test/talktome.php“, a php 4 getcwd() in that file will return the path “/test” while PHP 5 will correctly return ‘/’.

To resolve this, this next call works even better:
echo basename(dirname(__FILE__));

Does anyone want to do some speed tests to see which is faster after 10,000 calls? Let us know your results.

Mafia Wars: Cuba – New BETA Screenshots

A few weeks ago, I’d been asked to beta test the new levels for the popular Zynga Mafia Wars game. Mafia Wars is arguably the most popular and successful of the social media games developed by the recently Venture Capital funded company Zynga. To date, the 1.5 year old, profitable, VC backed Zynga has raised 39 Million dollars in funding. As Mafia Wars is widely popular, there is bound to be great interest in this new Zynga release.

The story starts as I was about to crash for the night and made the mistake of turning on a computer screen. Imagine my surprise when I noticed a “Fly to Cuba” button on the top of my Facebook Mafia Wars page. In this beta release, there are new jobs hidden till you complete the next level and there are loads of new help topics and weapon descriptions and loot items revealed. I’ve made certain to record as much as I can tonight and you can look forward to finding more information in The Code Cave about this new Mafia Wars module.

My Mafia Wars links:
Be My Friend on Facebook
Join My Mafia
Promote me, [LSM] Capt. Queeg, if it will help you
Send me Black Mail Photos! I need 130 more

However, as I am likely to pass out on the keyboard at any moment, for today, you’ll have to be content with these tall images of the Mafia Wars: Cuba Home page and its first Jobs page. Enjoy:

This is the initial page for Mafia Wars: Cuba. Notice the Shared Mafia Wars Resources.
This is the initial page for Mafia Wars: Cuba. Notice the Shared Mafia Wars Resources.
Mafia Wars: Cuba - Jobs -  El Soldado - The Soldier
Mafia Wars: Cuba - Jobs - El Soldado - The Soldier

WordPress/WordPress mu Merge Definitively Confirmed

There’s been rumor and confusion over the last week about whether WordPress and WordPress mu were merging as Matt seemed to imply at WordCamp SF. The announcement was so shocking that the true meaning was uncertain. For example, the avid WordPress evangelist Lorelle was left with the impression that WordPress.org would become a community site. Thankfully, Donncha, WordPress mu’s lead, gave the conclusive word on the subject this morning:

Basically, the thin layer of code that allows WordPress MU to host multiple WordPress blogs will be merged into WordPress. I expect the WordPress MU project itself will come to an end because it won’t be needed any more (which saddens me), but on the other hand many more people will be working on that very same MU code which means more features and more bugfixes and faster too.

Donncha, I would view this with the honor it does you. It is not much of a stretch to say that with your work on mu, you’ve made a lasting contribution to the shape of world and how people get information and will relate to each other over the upcoming years. More and more and more sites are run on mu, while the whole buddy press/bbpress/mu paradigm is taking off and will change the shape of the web. The adoption of the mu’s features into the WP core is a signal of what is to come and it will be an exciting ride!

Congrats guy!

WordPress 2.8 Beta 1 Released

While I was rolling around near comatose yesterday WordPress 2.8 beta 1 hit the streets. We plan to do a thorough review of this project on Thursday at the Ohio WordPress meetup here in Akron, Ohio. So, I figured it would would be a good time to run it officially here in The Code Cave.

The upgrade process is as simple as always. Unzip the file, copy it over the existing files, go to wp-admin upgrade and click continue. When the official release comes out, I plan upgrading my wp-upgrade script as I still think it is useful. Even though WordPress itself has upgrade abilities within it, the full file backup and database backup that my script does, still provides added benefit. So, I’ll keep it around a while longer.

As for WordPress 2.8, you don’t need to fear about learning a totally new system from scratch. There are a number of nice changes and tweaks, but the basic interface remains the same. There are a lot of changes for plugin developers and the like, but the everyday users will see some things like the new widget drop zone that makes it easy to make a widget inactive without loosing its settings. I’ll be testing over the next few weeks to see what I’d consider note worthy for a release post. I used to even do a line by line comparison, but I don’t know if I’ll don’t be returning to that. For now you can read about the changes here.

If there is any part of this upgrade that you definitely think we should cover at the Ohio WordPress Meetup, please let me know so that I don’t miss it!

2 for 1 Deal for Facebook Mafia Wars

Send me 1 item on my wish list and put a message on my wall asking for any two items from this list and I’ll send them back to you. Make sure to provide a link to your profile or your profile name or I’ll not be able to find you. First Come: First Serve. So you might want to have a backup choice or two. I’ll adjust this page as I run out of stuff.

Of course if you want to do this you’ll need to:
Add me as a Facebook Friend
Join My Mafia
Promote me (I’ll give you at least a 13% bonus depending upon your level if you Promote me as your Bagman)

After less than 2 months of playing, I am a Level 160 Boss Mogul with master on every level up to underboss. I have 11 out of 14 achievements. I currently earn 111mil every 51 minutes. I’ve been leveling up 3 to 4 times every day, though I might hit 5 levels today. With >1000 mafia members, I’m really raking in the experience points just by other ppl using me in fights. So I should reach the max bagman bonus for you pretty quickly.

Here is what I am offering:

Ten of Diamonds
Monkey Sculpture
White Poker Chip

Ebony Cigar
Sky Cigar
Rose Cigar
Ivory Cigar
Turquoise Cigar
Gold Cigar

Eight of Spades
Nine of Spades
Ten of Spades
Jack of Spades
Queen of Spades

Topaz Ring
Opal Ring
Amethyst Ring
Sapphire Ring

Solid Tie
Striped Tie
Checked Tie
Geometric Tie
Dot Tie
Knitted Tie

Warhol Painting
Van Gogh Painting
Dali Painting
Monet Painting
Rembrandt Painting

Silver Cufflinks
Gold Cufflinks
Amber Cufflinks
Jasper Cufflinks
Agate Cufflinks
Onyx Cufflinks
Pearl Cufflinks

Mill Reef
Sea Bird
Arkle
Golden Miller
St Simon
Ormonde
Eclipse

9mm Semi-Automatic
.22 Pistol
Butterfly Knife
Brass Knuckles
.45 Revolver
Firebomb
Automatic Rifle
Semi-Automatic Shotgun
C4
Tactical Shotgun
.50 Caliber Rifle
RPG Launcher
Grenade Launcher

Stab-Proof Vest
Lucky Shamrock Medallion

Armored Truck
Prop plane

SxSW Wow!!!

A New Look

You may notice that there are a few things different around here! I am approaching the three year anniversary of The Code Cave and have decided to spice things up a bit. The site is now sporting a new theme on a new web host, its own VSP. And I’ve got a number of posts lined up to be published. The first of which is this one. My entry into the Blog World and New Media Expo Free Ticket to South By South West Interactive contest.

Sham WOW!

Now, I have to admit I was inspired by an infomercial that you simply can’t get around seeing these days. It’s Vince Offer‘s Sham Wow product:

Now if you haven’t seen that, surely you’ve seen the “Slappin your troubles away” Slap Chop. The excitment Vince shows for his favorite past time, of selling products everyone could use, is infectious.

I’m not the first to be inspired by his exuberance. Rhett and Link have given the commercial their full treatment and created this video:

And now… SxSW WOW!

My reaction ( major hat tip to http://twitter.com/markjaquith ) to Blog World and New Media Expo giving away a free ticket to SxSWi was simply WOW! and stare at the screen for screen for a while waiting for my brain to turn back on and finish processing every thing it had been ignoring from my eyes for the last 5 minutes. SxSW wow! And that was it! the vision was born within minutes of reading the article.

I shot some even fancier footage from my motorcycle showing the excitement of the 20 hour drive down to Texas, if that’s how I went (And yes, I would live stream the whole way). And had some other ideas to include, but the priorities fell to 1. Get the site transferred to the new host. 2. Make the site pretty enough to host the video 3. Get the blasted thing DONE!

So without any more ado, whatever that is, I present you with “SxSW WOW!” (uploaded at March 01, 2009, 10:43 PM PST):

I do need to thank my loving wife Denise Layman (aka Sorka) of knitting fame at KnitChat.com for all of her help filming with MS Movie Maker tips as I’d never used it before. Thanks Love!

Download hi res 600mb

Mentioned in the Video

Tim Bourquin founder of New Media Expo – who seems like a really nice guy And as far as I know he’s never consumed 20 times his weight in ANY type of liquid
Rick Calvert – Co-Founder of Blog World Expo who I know is a really nice guy
Jim Turner – aka Genuine, who is an excellent write of no little fame. I noticed that he happened to be the author of the contest post! And as far as twitter is concerned, yes, I’m pretty sure he is following me!

Sham WOW! Script

Since I had this file on my desktop I figured I’d share my script with you. Here are the original and new lines I used from the commercial:
O: Hi It’s vince with Sham Wow!
N: Hi it’s Brian and I’ve got a SxSW Wow! from Blog World Expo!

O: I’ll be saying wow, everytime I use this ticket.
N: You’ll be saying wow, every time you use this towel.

O: It’s like a shammy it’s like a towel it’s like a sponge.
N: It’s like a party, It’s like a confererence, I’ll be like a sponge, YAY ME!

O: Sham wow holds 20 times its weight in liquid.
N: SxSW attendees absorb 20 times their weight in liquid! Just ask Tim Bourquin

O: Look at this it just does the work
Why do you want to work twice as hard

N: Look at this, I’m doing work!
Why would I want to be working at home?

O: Made in germany. You know the germans always make good stuff
NOT USED: This is a gift from blog world expo, you know Calvert always makes good stuff…
REPLACED: Every SxSW Wow! comes pre-Rick rolled by (Rick) Calvert himselfs

O: Here’s some cola, wine coffee cola pet stains
Not only is your damage on top but
There’s your mildew. that is gonna smell you see that?

N: Here… here is my anxiety of how to get to SxSW. My sweat, my tears, my embarrassing stains,
Not only is it on top
But it’s down deep man

O: Were gonna do this in real time
Put it on the spill, turn it over
without even putting any pressure 50% of the cola right here. Following me camera guy
The other 50% the color starts ta come up.

N: I’m gonna stream this live
I put my SxSW Wow! on top and roll it
No Pressure man, No pressure and suddenly 50% of my worries are gone!
All that remains is the fun of getting there. You followin me (Jim) Turner, you followin me?

O: No other towel is gonna do that
It works like a vacuum.

N: And look at that
It works like a Valium.
No other ticket is gonna do that!
SxSW Wow!

O: See what I’m telling you.
Sham wow – you’ll be saying wow every time

N: See what I’m telling you.
SxSW Wow! – I’ll be saying Wow! all the time!

THANKS BLOG WORLD EXPO!

MySQL Founder Resigns from Sun over Quality of MySQL 5.1

A picture of MySQL founder Michael "Monty" Widenius

I first laid eyes on Michael Widenius, the original and principle author of the MySQL database software at the 2008 MySQL Conference in San Jose.  Michael, who is more commonly known simply as “Monty”, had recently had his pride and joy, the MySQL AB company purchased by Sun Microsystems. I’d say that just about every attendee was extremely nervous about the future of MySQL, and every (new) Sun employee was eager to say “Oh, the purchase was great thing!”. There certainly was a Sun head hunter at every corner ready to hand out an application form (and a pair of boxer shorts or two).


MySQL_Boxer_shortsI left the conference having learned a lot of the techniques Lee Newton would be soon applying to the b5media database architecture. But far as the Sun purchase was concerned… I felt a little less safe. It was worrying that something that important was not quite as secure as it once was.  There was no indication something bad was about to happen, but the way things were, it was sure to be painful if something did.

So now not a year later, Monty announced today that he has quit because Sun released MySQL 5.1 without first resolving significant flaws despite Monty’s strenuous objections. Monty previously released a detailed list describing some of the “many known and unknown fatal bugs in the new features that are still not addressed.” My take from the article is that we should consider MySQL 5.1 should be considered a 5.0 maintenance release with pre-release beta features included.

Obviously Monty had spoken up to the higher ups at Sun prior to the release, but as he explained this had little affect.  I think that the open source world collided heavily with the corporate reality of “Cost, Schedule, Features, or Quality – Choose 3”. In the open source communities, the choice is simple, the schedule rarely if ever enters the mix. In this corporate battle, it obviously was one of the three chosen. Monty had been seen this coming early on and had been very vocal even back in April 2008 (see page 19) calling for Sun to “Create a release policy and independent release policy board that can’t be manipulated by people in charge of server development (to not allow anyone to sacrifice quality to reach personal goals)” Whoa… “To reach Personal Goals” – even then it sounded to me like he had someone in particular in mind. Additionally, from another comment later in the keynote: “Sun is more opensource/free software friendly than MySQL AB has been lately and is driving MySQL in the right direction” it seems obvious that there was a power struggle going on. After all MySQL AB was co-founded by Michael and he should have had significant influence over the company’s philosophies. I don’t know the rest of this particular sub-plot, but I’m certain there is more to be told.

In any case, in light of MySQL 5.1’s quality issues at time of general availability Michael tells us he immediately quit  but was talked into giving three months months to Sun for reconciliation and putting things right. That stretched into seven months, but the end result was the same. Michael announced today that he’s resigned and will be creating his own version of MySQL called MySQL-Maria which will will incorporate all MySQL updates but include rewrites and additional code to improve stability. It will be primarily developed by a new company he is forming named Monty Program Ab which will be “a true open source company”. I’m still not sure what that means, but I guess I could read up on it in more detail, if I wanted to.

So, what does this mean? Is it a good thing? I guess it is good that someone is out there fixing known bugs in MySQL, but won’t that happen anyway with an open source project? It’s great to see another company formed to further the open source movement, but can a MySQL standards war be beneficial?  Given the adoption rate of new MySQL releases, does it even matter that 5.1 was released? It’s not as if ISPs will install it anytime before 2010 by which time there will be patches.

In the end, from the clues I’ve seen I suspect this episode occurred due to a personal, philosophical dispute that Monty didn’t win. Regardless, I wish him success with his new project and thank him for providing a tool that I use ever day: MySQL.