Wednesday, December 29, 2010

Force vmware Fusion guest to shutdown or restart

problem: VMware Fusion guest is locked up and won't shutdown

You want to force a shutdown/power off OR force a restart/reset

solution: use the alt/option key

Open the Virtual Machine menu and press the key and you will see the menu options change to their alternatives. Choose one of the options, e.g. Power Off
I believe this works from version 2 onwards.

citation:

Props to: Team Fusion @ VMware Community Blogs

Tuesday, December 21, 2010

Parsing NCSA combined log format - working with columns

problem: You want to work with columns of an NCSA combined log file

You might have some apache or squid NSCA combined based logs. For example you might want to get the UserAgent column so you can sort and find unique values

solution: Perl Regular Expressions to the rescue!

citation:

Props to:
Me
The PHP Cookbook

Monday, December 6, 2010

iTunes is out of sync with ID3 tags

problem: iTunes is out of sync with ID3 tags

  • You've used a tool to manage your MP3 ID3 tags and iTunes is out of sync with the changes
  • You would like to refresh ID3 tags on selected tracks in iTunes or your entire iTunes Library

    impact: grrrrrr

    This is rather frustrating, all that hard work to manage your tags and iTunes gives you the middle finger and your ID3 tags are out of date...

    solution:

    This should work for _ALL_ iTunes versions up to the time of writing, which is 10.1.
    In theory it should also work on all platforms too.
    1. First off, close iTunes if open, make sure its dead
    2. Make sure the tracks you want to work with are not read only
      You can protect iTunes from modifying your tracks by settings files to read only
    3. Open iTunes
    4. Select the tracks that you want to refresh
      You can select _ALL_ but be warned the more you select, the longer the process will take. I strongly suggest being selective, at least until you've mastered the technique
    5. With the tracks selected press CTRL+I
      You can also right click or activate the context menu and click "Get Info"
    6. Make sure NO checkboxes are checked
    7. Select the sorting tab
    8. Enter anything you like into a blank sorting field
      This will check the checkbox for the specific field
    9. Double check only the sorting checkbox is selected
    10. Click OK
    11. iTunes will show a progress bar as it applies changes
    12. You should see the tracks now have the latest ID3 tags
    13. Repeat to remove the sort tag when your happy
    Note a positive side effect of this operation... any missing files that were selected will now have the exclamation mark next to it, might be helpful to some :)

      citation:

      I've combined methods from these pages
      Props to Kishore @ Chinto's blog
      and Yoricko @ Harmonic Mixing Community

      Wednesday, September 22, 2010

      Force a LAN DHCP lease to renew

      If your having issues with an existing lease, perhaps an ip conflict... and you want to force your windows DHCP client to get a new IP address then try the following:
      1. ipconfig /release
      2. reboot
      This has worked for me on Windows 7, so it probably works on recent windows versions too.

      A simple ipconfig /release and ipconfig /renew doesn't cut the mustard in most cases...

      No idea if this would work for a WAN lease, worth a try I guess.

      Sunday, September 12, 2010

      Automating ssh public key authentication with keys that have passphrases

      This subject has burnt a day of my time this week... upon re-reviewing man ssh-add I should of got to solution much quicker. At first I was annoyed and the lack of documentation... perhaps now I'm just annoyed at how its written... because I failed to read it thoroughly enough the first time!

      Enough rambling.

      A large amount of my automation with bash involves remote host execution... most scripts I deal with require humans to do something like:

      $ eval $(ssh-agent); ssh-add ~/.ssh/some-key
      ... enter some password if the key has one
      $ ./some_script $servers $work

      Where $servers is a file or list of hosts to be affected and $work gives the script an indication or direct instruction on what to perform on the remote hosts. a simple example of ./some_script:

      #!/bin/bash
      servers=$1;work=$2
      for $server in $servers; do
      ssh $user@$server "$work"
      done

      For some scripts, the time had come to make them part of a workflow and automate them further... the the scripts had to run completely autonomously and return the result of their execution to the workflow.

      So, due to a number of factors, time being a big one, I decided to look at how to input a password to authenticate the remote access. I know this has security implications but it is what it is for now... to be improved in time.

      I wanted to avoid having to use the expect command and I wanted to keep the existing authentication keys. So I set about the manuals for ssh, ssh-agent and ssh-add.

      Up popped $SSH_ASKPASS... The primary mistake I made which burnt most of my time researching this... was not realising $SSH_ASKPASS ONLY applies to passphrases from public key authentication. It does not apply to interactive password authentication.
      In layman's terms $SSH_ASKPASS provides the path to the executable that will output the passphrase for the given key.

      So with that cleared up, my solution looks like this:

      # setup env
      $ export DISPLAY=none SSH_ASKPASS=/home/$user/output_phasephrase.sh;
      # create authenticated session
      $ eval $(ssh-agent); ssh-add /home/$user/.ssh/some-key < /dev/null

      First set up the env for ssh-add and secondly add the key. After the key is added successfully, the shell/script session is fully authenticated for any remote hosts that recognise the key.

      The output_passphrase.sh can be as simple or as complicated as you'd like. For example:

      #!/bin/bash
      echo 'some-passphrase'

      Would work but has security implications! Something like this would be better:

      #!/bin/bash
      sudo gpg -d /home/$user/key-passphrase.txt.gpg 2> /dev/null

      Monday, August 9, 2010

      problem:
      You're using Outlook 2010 with an exchange account, full 'non instant' search and indexing is working as expected, however instant search and "search tools" options/buttons are disabled/grayed out!

      impact:
      counter productive and annoying, prevents fast searching and requires much more typing to yield results.

      solution:
      Ensure you're exchange account is using "cached mode" under the account settings