Customising the Command Prompt

If you don't currently follow the Command line Kung Fu blog, I highly suggest you do! Originally started back in February this year by Paul Asadoorian (of PaulDotCom), Ed Skoudis and Hal Pomeranz, each week they publish solutions to challenges posed to each other, using only the command line utilities included on a default installation of Windows, Linux and Mac OS - many of the published solutions contain really useful snippets of code to include in your own scripts.

Something that was covered in Episodes #28, #49 and #52 was customising the command prompt in various ways. On my own Windows systems I now include the following command prompt customisation by default:

30/09/2009 13:30:34.98 C:\>

Why? The biggest benefit is knowing when commands were started, and when they completed. Many tools don't provide feedback with time and dates, and so by the nature of the date and time being printed on screen each time a prompt is provided, you get a quick and dirty way to see how long a command took to execute.

Setting the prompt temporarily can be done with the 'prompt' command (or 'set prompt'), while making the change permanently can be done by adding an entry to the registry - both can be seen below.

Command_prompt_2

In addition, my prompt also displays how many paths are on the pushd and popd stack, as also seen above.

Indisposable Tools - Notepad++, a Notepad Replacement for Windows

Microsoft Notepad is probably (and unintentionally) one of my most used utilities, for example, when when stripping text formatting from content cut/copied from Word or Internet Explorer, or editing batch, vb, or <insert language here> scripts.

It's very quick to bring up Notepad (Windows + R, notepad <return>) as quick dumping ground for the clipboard, and uses very little resources, however it does have it's limitations - Unix carriage returns, no regular expression support to name but a few.

A highly recommended tool open-source replacement, which has now become one of my indisposable tools, is Notepad++.

"Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License."

"Based on a powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment."

Some of the key benefits, for me anyway, include:
  • Syntax Highlighting and Syntax Folding for various languages (including XML, HTML, Perl, Python, VB/VBS, Batch etc)
  • Multi-Document and Multi-View allowing you to view multiple documents and have multiple views between them, or in the same document
  • Regular expression Search/Replace is fully supported
  • File status Auto-detection, which is particularly useful when working on live files, such as logs etc
Scrsh_multiview

There are also a large number of plugins, which extend Notepad++ even further.

Installation is straight forward - just download the latest installer (or the .zip file), and accept all the defaults. I can also highly recommend installing the Notepad++ launcher, which will allow you to replace Notepad completely:
  1. Backup your original Notepad.exe
  2. Copy notepad.exe which comes with this package into 4 directories (in given order) :
    - c:\windows\servicepackfiles\i386
    - c:\windows\system32\dllcache
    - c:\windows\system32
    - c:\windows
  3. When you replace notepad.exe in c:\windows\system32 and c:\windows, a "Windows File Protection" message box appears, click Cancel. Then another message box appears, click OK.
  4. Modify you registry (if you use installer to install your Notepad++, you don't need to do this step): Create key \HKEY_LOCAL_MACHINE\SOFTWARE\Notepad++, then add your Notepad++ full path as the default value of this key. In my case, it's C:\Program Files\Notepad++.
If you need any further information, check out the NpWiki++.

The Five Minute Guide to MacPorts

Underneath Mac OS X is Darwinthe Unix-derived core that provides the underlying foundation for Mac OS X, and although born of BSD, by default many tools you may be used to on a *nix system are not present.

Architecture

And so in steps The MacPorts Project as an easy way to install open-source software onto your machine.

"The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system. To that end we provide the command-line driven MacPorts software package under a BSD License, and through it easy access to thousands of ports that greatly simplify the task of compiling and installing open-source software on your Mac."

For example, I recently rebuilt my Mac with Snow Leopard, and needed wget back on the system. Here is a quick how-to on getting MacPorts + wget installed:
  1. Download and install the appropriate MacPorts dmg file from http://distfiles.macports.org/MacPorts/ - you can accept all the default installation choices. In my case, I downloaded MacPorts-1.8.0-10.6-SnowLeopard.dmg
  2. Once installed, open up a Terminal, and type 'sudo port selfupdate' and enter your password when prompted - this will make sure your local ports tree and base files are all up to date.
  3. Finally, installing a package is as simple as typing 'sudo port install <package name>', so in my case I installed wget with 'sudo port install wget'. All required dependencies are also automatically installed.
MacPorts currently has over 6200 ports distributed among 92 different categories, and more are being added on a regular basis. If you need further information, check out the official docs.

 

Adding a tape drive to Netware

It's been a while since I've had involvement with Netware configuration, but I've recently had to add a tape drive to a Novell Netware 6.5 SP6 server - the key point is to update STARTUP.NCF on the DOS partition to include the required drivers for the SCSI card. For example, I added the lines:

LOAD NWTAPE.CDM
LOAD LSIMPTNW.HAM SLOT=2

The PCI card is loaded into PCI Slot 2 (hence the line above) - you can check which slot your device has been installed to by checking Novell Remote Manager (http://yourserver:8008/ or https://yourserver:8009/), under 'Manage Hardware' -> 'PCI Devices'. Once the driver has loaded (you can load the above drivers manually, without having to reboot the server), check the device is visible using 'LIST DEVICES' on the console.

§

Andrew G. Allen

Andrew G. Allen

Information Security Evangelist, Technologist, and Internet Junkie.

http://www.andrewallen.co.uk/