Add an Open With option to the global context menu

Have you ever wanted to add an option to that ornery right click context menu so you could open whatever file you just clicked on with whatever the heck you please? I know I have, and here is a quick tip to do just that! Whether it’s your favorite text editor, or another app that you want for some reason, you can easily add an Open With option to the context menu by modifying and then importing this registry file.

Continue reading

How to generate htpasswd compatible passwords with PHP

Sometimes we have to generate passwords in our code, no problem. But what about when you need to generate a password that is compatible with the htpasswd command, as in the password is the same as what would be generated by htpasswd? Well, if you are using PHP, you can use this function that I posted in the forums. Check it out …

Bash script tip, cutting from variables

Ok, here is a quick tip that has come in handy quite a few times in my days writing shell scripts, for example in bash. Let’s say, for whatever reason, you need to chop off the end of a string (like a variable). Chopping the beginning is easy, just use the cut command, but in order to chop the end you have to know how long the string is so you can tell it where to start. In this example, we are going to us the wc command to figure out how long the string is, and then subtract 1 to cut the last character. You can subtract however many you want depending on how many characters you want to cut. Check it out … Continue reading

Simple PERL file backup script

I am one of those type of people that like to make backup copies of files before I tinker with them, especially when I am modifying important files like system stuff. It’s always a good idea to make a backup copy before you edit something so you can put it back if you break it. For that reason, I wrote this simple little PERL script that I then put somewhere in my path so I can run it from anywhere. I call it simply “bu” so that it’s easy to type and use. What it does is copy the target file you specify, to a file of the same name only with a date stamp appended to it. I have found this to be a really handy tool, so I thought I would share.

Take a look at the script here.

Check it out, I hope you find it as useful as I have.

Solaris 10 Zone Creation Script

One of the best things about Solaris 10, from Sun Microsystems, is Zones or Containers.  They allow you to create virtual OS installs on the same box, yet have them quite separate from each other.  Processes are segregated, resources can be capped, the options go on and on.  Here I have a PERL script (have I mentioned that I love PERL lately?), that makes the creation of zones a snap.  The only thing to edit in the script is at the top, where you set your zone base directory, as in the directory that will hold the zones your create.  I am a simple man, and usually just stick them all in /data/zones, with /data usually being a separate mount point and thus separate I/O path.

***NOTE: This script was written a few years ago and I have no Solaris 10 machine to test it on NOW, so I offer this script AS IS with NO WARRANTY AT ALL! I hope it will help you, but if problems arise from it’s use, you cannot hold me responsible. That being said, if you find it useful (as I did when I wrote it) please let me know that it is still working.***

#!/usr/bin/perl

# This will be the base zone dir used with zonedir below
$bzd="/data/zones";

system(clear);
print "\nSolaris Zone Maker\n";
print "---------------------\n\n";

print "What is the name of the new zone to be created? ";
$newzone = ;
chomp($newzone);

print "\nWhat is the name of the directory to be used for this zone? [$newzone] ";
$zonedir = ;
chomp($zonedir);
if (!$zonedir) {
 $zonedir = $newzone;
}

print "\nWhat is the IP address to use? ";
$newip = ;
chomp($newip);

print "\nWhat is name of the ethernet interface to bind the IP address to? (ex: bge0) ";
$ethint = ;
chomp($ethint);

print "\nDo you want to inherit standard directories (lib,platform,sbin,usr) from the global zone? [yN] ";
$inh = ;
chomp($inh);
if (!$inh) {
  $inh = "n";
}
if (($inh eq "y") || ($inh eq "Y")) {
  $isw = "1";
} else {
  $isw = "0";
}

print "\n\nPlease verify the following information:\n\n";
print "           Zone Name: $newzone\n";
print "      Zone Directory: $zonedir\n";
print "     Zone IP Address: $newip\n";
print "  Ethernet Interface: $ethint\n";
print " Inherit Directories: $inh\n";

print "\nAre these entries correct? [Yn] ";
$yn = ;
chomp($yn);
if (!$yn) { $yn = "y"; }
if (($yn == "y") || ($yn == "Y")) {

 $of = "/tmp/zccfs10.tmp";

 # Create the zonecfg command file
 `echo "create -b" > $of`;
 `echo "set zonepath=$bzd/$zonedir" >> $of`;
 `echo "set autoboot=true" >> $of`;
 if ($isw == "1") {
   `echo "add inherit-pkg-dir" >> $of`;
   `echo "set dir=/lib" >> $of`;
   `echo "end" >> $of`;
   `echo "add inherit-pkg-dir" >> $of`;
   `echo "set dir=/platform" >> $of`;
   `echo "end" >> $of`;
   `echo "add inherit-pkg-dir" >> $of`;
   `echo "set dir=/sbin" >> $of`;
   `echo "end" >> $of`;
   `echo "add inherit-pkg-dir" >> $of`;
   `echo "set dir=/usr" >> $of`;
   `echo "end" >> $of`;
 }
 `echo "add net" >> $of`;
 `echo "set address=$newip" >> $of`;
 `echo "set physical=$ethint" >> $of`;
 `echo "end" >> $of`;

 # Make the dir that the zone will live in
 `mkdir $bzd/$zonedir`;
 `chmod 700 $bzd/$zonedir`;

 # Now, create the zone dude!
 print "\nCreating the zone ... \n";
 `zonecfg -z $newzone -f $of`;
 print "Done!\n";

 # Install the zone
 print "Installing the zone, this will take awhile ... \n";
 `zoneadm -z $newzone install`;
 print "Done!\n";

 # Boot the zone
 print "Now booting the zone ... \n";
 `zoneadm -z $newzone boot`;
 print "Done!\n";

 # Remove the config file
 `rm $of`;

 print "\nZone setup complete, connect to the virtual console with the following command: \n";
 print "  -> zlogin -C -e\\@ $newzone <- *Exit by typing @.\n\n";

} else {
 die("Script execution halted.\n");
}