I've finally decided to switch most of my server operations to Linux. I happen to have a couple of old Pentium-II machines lying around, and although they won't run Windows (properly), I know they can run Linux without a problem. To prepare for this plunge, I have a collection of general Linux ebooks - including certification materials for the Red Hat Certified Engineer (RHCE) certification. I probably won't be taking the certification itself ($800 a pop?), but at the end of this exercise, I will have the same knowledge as those guys.
It was surprisingly hard to find a free version of RHEL 5. I know Linux itself is free, but all I kept finding on their site were subscription-based downloads. Forums everywhere suggest it should be free, but for hours I couldn't find a free download of the OS. I really just need a basic server build to do this "certification" on - my way of getting fully into the world of Linux.
The other motivation for interest in Linux at this time is the impending dumping of Windows XP support in 2009. If you didn't know, Microsoft will stop supporting and selling Windows XP next year - a setup that forces people to move to Vista. I don't want Vista (much heard about its headaches), so I am hoping that by that time I'll have proficient Linux experience to migrate all my crap to Linux when the need arises. I've heard much about Ubuntu being poised to penetrate the desktop market, so when I buy my next laptop (which will come with Vista - obviously), I want to be able to move quickly to Linux.
So much has changed in the world of Linux since I last worked on it. I probably should purge it from my resume until I am done with this exercise. I'm doing this in tandem with other projects I already had going - in fact, some might benefit from a migration to Linux servers.
Friday, May 09, 2008
Thursday, April 17, 2008
System Disk And Drive Letter In Perl
There's no easy way to discover the system disk and drive letter on Windows, so I came up with this tedious work-around. Basically, you use Windows Scripting Host (WSH) to write a file that Perl can then read. Someone may wonder why I'm not using Win32:: packages - well, they don't implement the whole CIMv2 spec, so you'll begin running into errors such as Win32::OLE(0.1707) error 0x80020009: "Exception occurred", smartly described as a "Generic Error". It's a nightmare to dig through MSDN to figure out what the heck an ambiguous error like this means.
So the simple workaround: write a VBScript file that contains this code:
There are zillion ways to write this code to the filesystem in Perl; I leave that up to you. Execute the file (with a .vbs extension) on the system shell (DOS), and have Perl read the file theboot.txt (or whatever you call your file) - parse it for the physical disk number (given by Win32_DiskDrive.DeviceID) and the drive letter (given by Win32_LogicalDisk.DeviceID). Associating the two WMI classes is weird, as the code above shows, but it works. In the code, the file is written in the format [disk_number] [drive_letter].
Note that I use for-loops in this workaround, so if you have multiple boot disks, only one will be discovered.
Also, don't rely on DISKPART for this job, especially if you are scripting things. It works well interactively, but I've found it unreliable on systems with large drive counts - in such cases, the disk number won't always be the same.
This workaround essentially saved my day: reliance on diskpart had cost me a couple of lost OSes as it sometimes reported that there was no system partition or could not find drives whatsoever, especially if you had a lot of drives. The WMI/CIM solution seems bullet-proof - for now.
So the simple workaround: write a VBScript file that contains this code:
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
For Each objDrive In colDiskDrives
strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
Set colPartitions = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
strDeviceID & """} WHERE AssocClass = " & _
"Win32_DiskDriveToDiskPartition")
For Each objPartition In colPartitions
If objPartition.BootPartition = True Then
bootinfo = objPartition.DiskIndex
Set colLogicalDisks = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
objPartition.DeviceID & """} WHERE AssocClass = " & _
"Win32_LogicalDiskToPartition")
For Each objLogicalDisk In colLogicalDisks
bootinfo = bootinfo & " " & objLogicalDisk.DeviceID
Next
strOutputFile = "./theboot.txt"
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
objOutputFile.WriteLine(bootinfo)
objOutputFile.Close
Set objFileSystem = Nothing
End If
Next
Next
There are zillion ways to write this code to the filesystem in Perl; I leave that up to you. Execute the file (with a .vbs extension) on the system shell (DOS), and have Perl read the file theboot.txt (or whatever you call your file) - parse it for the physical disk number (given by Win32_DiskDrive.DeviceID) and the drive letter (given by Win32_LogicalDisk.DeviceID). Associating the two WMI classes is weird, as the code above shows, but it works. In the code, the file is written in the format [disk_number] [drive_letter].
Note that I use for-loops in this workaround, so if you have multiple boot disks, only one will be discovered.
Also, don't rely on DISKPART for this job, especially if you are scripting things. It works well interactively, but I've found it unreliable on systems with large drive counts - in such cases, the disk number won't always be the same.
This workaround essentially saved my day: reliance on diskpart had cost me a couple of lost OSes as it sometimes reported that there was no system partition or could not find drives whatsoever, especially if you had a lot of drives. The WMI/CIM solution seems bullet-proof - for now.
Saturday, April 12, 2008
Developing PHP On NetBeans
I'm finally making the move to developing in PHP - or at least I must for the time being because of an important project I am working on. To make things easy on myself, I need a familiar development environment - NetBeans 6.x is just perfect for that. Here's how you set up NetBeans to talk PHP.
- Ensure you don't have previous installations of PHP. Presence of such will confuse the hell out of your new installations.
- Download the Wamp server. This package contains an Apache HTTP web server, MySql database, and the PHP engine, along with some admin utilities and a Wamp server console. Believe me, this stack takes the nightmare out of configuring PHP on Windows.
- Download the PHP plugin for NetBeans: Tools | Plugins -> Available Plugins tab -> Search [php]. Install the PHP scripting plugin, which includes an editor, runtime, and documentation. We probably won't use the runtime that comes with this plugin, as we need to use Wamp and other debug tools that it does not support. NB will need to restart after this install.
- File | New Project ... -> PHP | PHP Project [Next] -> (set project properties) [Next].
- Web server configuration: click [Manage] -> Connection name = Wamp2, Local web server with file access [Next].
- Manual configuration [Browse] to %where_you_installed_wamp%\bin\apache\apache2.2.8\conf\httpd.conf for the Apache config file. [Next]
- Http server settings - just change the port number to something no other app is using. I choose 81 on localhost (Remember to update httpd.conf to listen on port 81 as well).
- Finish up and close the dialogs. NB creates a new project and opens index.php for you to edit. You can start wil basic HTML in a .php file. If on running the project you see a good page, all is well.
Friday, March 28, 2008
Lots Of Free PC Utilities
I happen to also be a PC Service Technician (aside from everything else I do for work), and I survive on having the right utilities to service your computer whenever you call on me. PC Magazine is running an article that comprehensively reviews over 90 utilities you can use to tweak your Windows PC. I spent all evening pretty much checking out all the free ones (not evaluation copies) I didn't already have, and I'm quite impressed. Most are small downloads that install cleanly (no need to reboot) and are unobtrusive in your daily computing tasks.
Missing from the list are some on my wish list:
Nonetheless, the PCMagazine's list is a good start for someone wanting to milk more from their Windows system. There's just too much stuff out there that perhaps it all couldn't be covered in one article.
My personal favorites from that list:
Missing from the list are some on my wish list:
- A tool to convert movies from DVD, AVI or YouTube to iPod format easily. My current setup takes all night to rip a DVD - but it works.
- Networking tools such as one that can load-balance network bandwidth between multiple NICs on a system. Theoretically, if I use a wireless card and regular ethernet, I should have double the bandwidth, right?
- Program backup - a tool that can backup individual programs. Say, if I want to backup my MS Office, this tool should know which files, registry keys, DLLs, etc that are needed so that you can make programs more portable. Something that goes beyond System Restore and regular file-based backup/restore.
- A daemon to lock up your registry and startup folders (such as Adaware's Adwatch used to do). I having to manually clean up these areas once in a while.
- Optimization tools - anything that'll make your machine run faster.
- CD/DVD copyright restrictions cleanup. After a while, DVD players refuse to play encrypted CDs and DVDs because someone thoughtlessly decided that protection by region should be tracked.
Nonetheless, the PCMagazine's list is a good start for someone wanting to milk more from their Windows system. There's just too much stuff out there that perhaps it all couldn't be covered in one article.
My personal favorites from that list:
- IrfanView = See any image file and most digital videos, convert files to other formats and do some quick editing and annotation.
- Microsoft PowerToys = Useful tools that don't come with Windows, especially SyncToy, ClearType Tuner, Open Command Window Here, Alt-Tab Replacement, Power Calculator, Virtual Desktop Manager, Taskbar Magnifier, and Webcam Timershot.
- FreeCommander = Much better than Windows Explorer in controlling your files.
- QTTabBar = Advanced, tabbed interface.
- 7-Zip = No more expiration popups from WinZip and Winrar, and it does better zipping up stuff in a variety of formats.
- TrueCrypt = For those files for your eyes only. I don't think Administrators can get past this. Good for USB thumb drives.
- TeraCopy = If you are tired of single-file copying or having to start over when something goes wrong.
- FileZilla = New favorite FTP client. Supports SSL too.
- µTorrent = For the file sharing nerd in you, torrents and many P2p networks are your friends.
- WinDirStat = Visual statistics of what's on your hard drives.
- Xinorbis = Even better file statistics of what's on your hard drives.
- System Information for Windows (SIW) = Their tagline of "everything you want to know about your PC" isn't wrong.
- Absolute Uninstaller = If you ever want to uninstall multiple programs all at once - instead of one at a time.
- Undelete Plus = Now you can recover files you didn't mean to delete. Watch for this program's cache, and empty it periodically.
Subscribe to:
Posts (Atom)