Solarum – Information For Everyone

Archive for the ‘UNIX’ Category

Aug
27

Bash function for making locate find exact matches

This is one of the coolest and most useful things to add to my UNIX/Linux profile that I have come across in a long time. I use the locate command a lot (slocate naturally) as I am sure all of us command line monkeys do. How many times have you been frustrated by the billions of lines of results flying by your screen, piping through more or less, trying to find the one nugget of goodness that you really need? Especially when you actually know the correct name of it, just not where it lives? This is where this comes in handy (this is where this? man I am eloquent)! Add this function to your bash profile (for some that’s .bash_profile and for others it might be .bashrc, depending on your nix flavor) and you can stop all of that. I haven’t tried this with other shells aside from bash, but I don’t see why it wouldn’t work.

Basically, this function uses the locate command to find whatever you are looking for just like you do, only it uses a bit of scriptology to filter it down to the exact match of what you are looking for. Yep, that’s right, the exact match! This little tidbit can really help out when you are looking for something, take a look:

## BASH locate function for exact match
## Thanks Dark_Helmet : http://solarum.com/v.php?l=1149LV99
function flocate
{
  if [ $# -gt 1 ] ; then
    display_divider=1
  else
    display_divider=0
  fi
 
  current_argument=0
  total_arguments=$#
  while [ ${current_argument} -lt ${total_arguments} ] ; do
    current_file=$1
    if [ "${display_divider}" = "1" ] ; then
      echo "----------------------------------------"
      echo "Matches for ${current_file}"
      echo "----------------------------------------"
    fi
 
    filename_re="^\(.*/\)*$( echo ${current_file} | sed s%\\.%\\\\.%g )$"
    locate -r "${filename_re}"
    shift
    (( current_argument = current_argument + 1 ))
  done
}

It’s just that easy! Copy and paste this into your profile and add a cool helper addon companion function thingy :) I wish I could say I came up with this myself, but I didn’t, I found it in some forums posted by someone named Dark_Helmet (just like the attribution link in the script). I don’t know who you are Mr. Helmet, but I thank you for your sharing this with us all, and I am passing it on! Enjoy!

May
17

Solarum’s Open Source Project – nix32

I thought I would post some information about a project that I started a few months ago called nix32.  It’s hosted on SourceForge for the most part, with a handy website that I host myself mainly because it’s just easier to manage that way.  The basic goal of this project is to create native command line tools for Windows that operate much like the commands that we know and love from Linux and UNIX.  Things like ls, mv, cp, df and so on.  I have become so used to, comfortable with and productive with the UNIX/Linux command line environment, that when I have to leave it behind on Windows, it’s pretty tough.  Not just changing from what I am used to, but also because I think the command line of a UNIX/Linux server is much more powerful and flexible than the Windows command line, even including the power shell.

I have been working on the more popular commands, and I have a few basics out now with basic functionality.  I hope to have more and better (improved) tools in the future.  I am writing everything in PERL and then compiling each one on Windows as a standalone exe using tools from ActiveState, and so far, they run very nicely.  It’s all completely open source, you can download the PERL scripts as well as the executable files if you want to take a look or help improve them.

Now, I know you can get similar results with other projects and products out there, CYGWIN comes to mind first.  However, that’s a whole separate shell and almost a little mini-Linux setup in and of itself, especially looking at the directory structure after it’s installed.  Here with the nix32 project I wanted to have native Windows executables that you can stick in your path somewhere and call right from the Windows Command Prompt, without ever leaving the Windows environment and without having to install anything.  So far that is exactly what we have, just copy the files somewhere, make sure it’s within or added to your PATH variable, and you are good to go!

So check it out, see what you think, spread the word and maybe even help out a bit and crunch a little code too.  Do whatever you feel and keep both feet on the wheel … or, keyboard maybe.  :)

Dec
6

Solaris patchadd Return Codes

I just posted some new goodness for all of the Solaris admins out there.  I have compiled a list of return codes from the patchadd command for both Solaris 9 and Solaris 10, and it has come in very handy over the ages.  So, I thought I would share.  Take a look at it here, and don’t forget to check out the entire library with all sorts of information in it here.  Enjoy!

Oct
4

Verizon Email Update and Solution

You have heard me share information about the fiasco that Verizon created.  In case you haven’t heard, I’ll recap quickly.  In the name of fighting SPAM, Verizon decided that they would block ALL port 25 SMTP traffic on their network for all of their ISP customers.  That means that anyone and everyone that uses Verizon as their ISP (DSL, FIOS, Dial-up, etc) cannot use any third party mail server or service that is configured to use the industry standard port 25.  That’s just plain stupid, but I have complained about that already.

I was in a quandary with this one, or maybe a catch-22 is a better term.  If I didn’t do anything about this “problem” that Verizon created, then all the people that I host email services for that use Verizon as their ISP are now out of luck.  They can’t send mail through their (read: my) mail servers.  So, I can just change the port that sendmail listens on, right?  Yeah, I could, and then my Verizon tethered customers can send mail again … but, all my other customers that don’t use Verizon have to change their email client settings too, since they would still be sending through port 25.  OK, I didn’t want to go down that road.  I wanted to fix the problem with the least impact on everyone. Read the rest of this entry »

Aug
3

Latest Solaris 10 Patch Cluster Is Broken

Thought I would share this with anyone out there that manages Solaris 10 servers.  In my case we were working with Sparc, but x86 might be affected as well.  I’ll skip all of the gory details, but basically what we ran into was a problem with the dependency matrix for a kernel patch (I believe the patch number is 141414–07).  What does that mean, you ask?  Well, it means that the kernel patch got applied via the patch cluster install script, but without the requisite dependencies being satisfied.  Yeah, ouch.

The servers in question would then panic as soon as you tried to bring them back up, and I mean panic hard.  You couldn’t even get into single user mode.  We spent hours on the phone with Sun support (this is where we finally found out about the dependency problem) to no avail.  Sun has really gone downhill in the last few years, and pretty much like a rock since Oracle bought them.  Their answer was that they can’t test everything and we had to figure it out on our own.  Yikes, what are we paying for support for again???

We ended up having to go back and restore from tape, but since we couldn’t boot into single user mode we did the old net boot from the jumpstart server trick and then restore from tape.  All in all it was not fun, but we made it through it.  One last thing, we had some servers that were OK with the patch cluster.  I think it depends on the release of Solaris that you are running.  The older installs did not have the proper dependencies, but the newer installs did.  I just wanted to put this out there as a heads up for anyone else getting ready to patch up a Solaris 10 box, be careful cause you might make a brick.

Hope that helps!

Apr
20

Oracle Buys Sun Microsystems

Or, the end of the tech world as we know it.  Maybe that’s too harsh, time will tell.  I know one thing for sure, Oracle stepped up with an offer that was only $400 million more than IBM was tossing around (I know, “only”, but when you are talking $7+ billion it’s not so much), and I bet IBM is now pretty mad at themselves.  Not just because they let Sun get away, but more importantly because Oracle with all of Sun’s technology under their belt, just became a veritable behemoth competitor.

I can’t say that Oracle buying Sun is worse than IBM buying Sun, I think either would have been bad, but I do think that IBM would have made more of the technology that Sun has, especially in the hardware arena.  Most people already run Oracle on Sun, but I think Oracle was angling the software more than the hardware.  Now they have the whole “stack” sewn up.  They have been re-branding Red Hat Linux to provide “their own” operating system, but now they don’t have to because they really do have their own operating system with Solaris.  One that lots of people prefer for running Oracle versus Linux and especially Windows.  Now Oracle can provide the application, the database, the operating system and the hardware platform to run it all on, all in one nice bundle.  I have come to think of it as the “O-Stack”.  Now, instead of a LAMP stack, Oracle will be pushing their O-Stack.

I just hope that the folk out there that have a considerable investment in Sun (me included), not only in SPARC, but also their X86 line, didn’t just get screwed.  Can Oracle keep the support going?  Will they keep the hardware lines going?  What will happen to Solaris, MySQL and Java (to name a few)?  Only time will tell, but I for one am not pleased with this announcement.

I’ll have more updates as I find information to share.

Search

Pages

Articles