Mark Minasi's Windows 2000/NT Newsletter

Issue #10 January 2001

To subscribe, visit http://www.minasi.com/nwsreg.htm. To unsubscribe, link to http://www.minasi.com/unsubs.htm. Visit the Archives at http://www.minasi.com/archive.htm.

What's Inside

News

Hi --

I hope everyone had a great holiday, I know I did.  I was planning to just stay home in Pungo for the holidays, but got a call from AvantGo, the folks that make that indispensable Web/PDA synchronization software (if you've never heard of it, the software grabs Web pages and stuffs them onto your PDA every time that you sync.  Then, when you're on the road you can read CNN, Space.com, or whatever grabs your fancy -- it's free and if you're not using it yet, check it out at www.avantgo.com).  They wanted a class in 2000 and the only time that we had left was the Wednesday and Thursday before Christmas.  I figured whattheheck, as long as I'm going I might as well make it a family trip, as one brother and his wife live in Santa Clara, not far from the AvantGo guys.  Then I jetted to Ft. Lauderdale to have Christmas with the two other brothers, their wives, and my favorite three nephews and a niece.  In my never-ending quest to infect youngsters with a love of Science, I got the two older ones (8 and 10) binoculars and showed them how to find Jupiter, Saturn, the Pleiades, Sirius, Orion and some other goodies.  

(What's that you say, you haven't a clue how to find Jupiter and Saturn these days?  Go outside between seven and nine o'clock and look overhead.  You'll see a very bright white star almost exactly overhead -- that's Jupiter, and you can see its moons even with a 10x binocular and a little patience -- give your eyes a little time to dark-adapt.  Saturn's the other bright star just a few finger-widths away, and if you're color-sensitive then you'll see that it's just a tad more yellowish than Jupiter.  No rings in the binocs, but even the lamest telescope should show the rings.  The Pleiades is the glowing cloud-like blur near Jupiter and Saturn; look in J and S's area and you'll notice something that's a big bigger than a star but mildly cloud-like.  Take a peek through binoculars and you'll see a whole bunch of blue-white stars like diamonds.  You're looking at a "star nursery," containing a number of brand-new stars.)

Santa was good to me, or at least I was good to myself Santa-wise, with a new four-wheeled toy.  I'm retiring the CRV for a Honda Insight, one of the new fuel/electric hybrid cars and no, you don't ever have to plug it in.  It's a peppy little two-seater that gets 60 MPG in the city and 70 MPG on the highway.  I'm not a car fancier -- I've always seen them as a necessary evil rather than a fun thing -- but this car's the most automotive fun I've had in a while.  If you're thinking about an ULEV (ultra low emissions vehicle) that's light on the petrol, I've got a writeup at www.minasi.com/insight.htm.  

Anyway, this month I've got an article that I've been meaning to write up and finally got to, about how to use Perl scripts on your IIS Web server.  It turns out that there are many, many extremely useful, cool, and often free server-side tools out there.  They'll work on IIS, but to make them work you need Perl and a few tips; you'll read all of that in this newsletter.

Calling All Canadians!

Many folks from Our Neighbor To The North have written asking when the public Windows 2000 seminars are coming to Canada, so I've put Toronto, Montreal, Vancouver and Ottawa on the "city vote" list.  A bunch of Montrealites responded nearly immediately, entering almost forty e-mail addresses, so we'll be working to find a location for that charming city.  But we hope to get enough interest to visit Toronto, Ottawa and Vancouver, so if you're interested then please visit www.minasi.com/pickcity.htm.  (I must admit that I've got a major vested interest in this; you see, I've done a lot of work in Ottawa and would love a chance to get up there in the summer.  I did a lot of business there, but it was all between December and March.)

Possible Class In Australia

Assuming that all of the contract stuff gets worked out, it looks like I'll be participating in a multi-day boot camp.  My contact, Rick Clarke, is planning to run the boot camp around 9-12 April and he's in the Adelaide area.  If you're interested then his e-mail is rick@chariot.net.au.

US Public Seminars:  Austin, Denver, Chicago, Kansas City, Tampa, Atlanta, Detroit, Minneapolis, NYC, Pittsburgh, Irvine, San Jose

February and March are chock-full of public seminars and I really hope you'll consider joining me for the one near you.  The first set of seminars in Philadelphia, LA, and DC went very well, and you can see the audience reviews at www.minasi.com/2krevs.htm.  I didn't just include the "cream of the crop" -- for honesty's sake, I included them all save for the ones that only commented on the hotel facility.  Find out more about the seminars at www.minasi.com/pubsems.htm.  We only need 15 people per session to make it worthwhile, so I hope that you or a co-worker will come join me for a pretty fact-packed but fun two days.  It's sort of Mastering Windows 2000 Server, Third Edition ... the live version.

Please Consider Posting Amazon Reviews

Many of you have sent me some extremely kind comments on my Windows 2000 Server, Linux, Windows 2000 Professional, and PC Upgrade and Maintenance Guide, and I thank you.  But I wonder if I could ask a favor.  If you've had a positive experience with one of my books, would you please consider posting just a few words on Amazon, even if you didn't buy the book at Amazon?  Yes, I know they've got that irritating new "privacy" policy, so I know that many of you aren't buying from them any more (in case you didn't know, apparently their new privacy policy is a "no privacy" policy, unfortunately), but Amazon has become a place that people go just to read reviews, even if they don't buy from Amazon.  It's even more helpful when the folks at Amazon keep old, irrelevant reviews, as they've done with the Mastering Windows 2000 Professional, 2nd Edition -- despite the fact that the book has been completely re-written, they've retained the old reviews for the first edition, terribly misleading potential buyers.  The only relevant review for the second edition is the recent one from "Tom from Concord," but the Amazon people refuse to remove the old ones -- it's terribly frustrating.

I quite literally meant just a few words, as Amazon's form won't take more than a hundred or so words, so it really is just a minute's work, if you'd be kind enough.  And you can find quick links to the Amazon pages with my books at http://www.minasi.com/covers/booklink.htm.  And thanks again so very much for all of your positive reinforcement, it really makes me want to work harder on every book!

Feature Article: Running Perl CGI Scripts on a Windows 2000 IIS Server

I recently needed to find a Web-based calendar system, something that would let people with the right access level see my calendar from a Web browser, or, with a different access level, to add events to my calendar.  Along the way, I found some truly great and either free or very cheap programs that filled that bill.

To see a few neat examples, look at www.cgi-resources.com.  In particular, check out Matt Kruse's free Web-based calendaring system at http://www.mattkruse.com/scripts/calendar/index.html.  It's simple, but useful and easily extensible, and -- need I say it again? -- it's free.  But that's not all you'll find when poking around the Web.  There are some really, really great apps written in Perl that run great on IIS.

The big trouble (for me, at least) was in figuring out just how do I run Perl scripts on my IIS server anyway?  After all, by default IIS hasn't a clue how to run Perl scripts. Here's a quick look at how to get Perl running on your server and how to install Perl scripts.

Installing Perl On Your Server

First, go get Active Perl for IIS at www.activestate.com. It's great and it's free. It ships as a single MSI file so just use the Windows Installer to put it on your system. Next, you'll need some Perl scripts, you'll need to know where to put them, and how to start them. IIS creates a default Web site at c:\inetpub\wwwroot and a scripts directory at c:\inetpub\scripts.

Using Notepad, create a file with the following contents, and save it in c:\inetpub\scripts under the name "hello.pl:"

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<HTML>Hello there!</HTML>"; 

Then fire up a Web browser and point it at http://127.0.0.1/scripts/hello.pl, and you should get the message "Hello there!"

TAR Versus ZIP: Unix Versus NT

Notice that Perl is an interpreted language, like VBScript and JavaScript - when someone distributes a Perl program, he's sharing the source code with you. Most useful Perl scripts aren't as simple as just one file, however - their application may involve a number of files and a particular directory structure. Perl applications tend to get packaged as a set of files and folder structures in a ZIP file. Or, rather, they're often packaged as both a ZIP file and a TAR file.

TAR is the Unix/Linux format for combining a lot of files together into one file - TAR has been around longer than ZIP and, although the Unix/Linux world also uses ZIP, you see TAR files more often. Given the choice, take the ZIP file.

But wait; if these Perl programs are all just a bunch of text files, then what's the difference between a Unix/Linux or an NT version of a Perl file? Strangely enough, a single, very small thing - end-of-line indicators.

In the Unix world, you indicate the end of a line with just an ASCII 10, a line feed. In the NT world, however, you indicate the end of a line with a carriage return and line feed. Thus, the Unix definition of "plain ASCII text file" and the NT/Windows definition of "plain ASCII text file" are just a wee bit different.

It's a small difference, and if you're willing to do some work then you can always get around it.  One way is with WordPad.  (And you wondered if it was of any value at all.)  If you tell WordPad to read a Unix text file, it'll recognize that it's a Unix text file rather than an NT text file, and will display the file correctly.  Then, if you write the file back as a text file, then WordPad will write out an NT text file, not a Unix text file, so WordPad is a Unix-to-NT converter of sorts. 

You can, then, always read a Unix text file with WordPad and then write it back as an NT text file, but who wants to do that for dozens of files?  It wouldn't be the end of the world, but it's enough of annoyance that you should look for the ZIP rather than the TAR version of a Perl script. And if the author didn't include a ZIP version, then either use WordPad or look around for a Unix/NT text converter.

But how could I have forgotten? You can use Perl to convert a file from Unix format to NT format! Just type the following at a command prompt on the computer that you've installed Perl on:

perl -p -e 's/$/\r/' < Unixfilename > NTfilename 

Just don't try specifying the same name for Unixfilename and NTfilename, or you'll erase the file.

Installing the Perl Script

Anyway, let's say that you've downloaded and unzipped your application into your c:\inetpub\scripts directory or wherever you keep scripts. The next problem is in figuring out exactly what command you're supposed to use to start the program. Sometimes it's the only file whose extension is ".pl." Or it might be a file without any extension at all, as Unix doesn't really need extensions the way that NT does, and so many Perl apps start life in the Unix world. There might be a README to give you a clue, but if not then look for the file with the extension ".cgi." The idea in the Unix world seems to be that you can sometimes use the .cgi extension to announce to a Unix Web server, "hey, this is the main file for this particular server-side script." (I know I said that Unix doesn't need extensions, but that doesn't mean that it never uses them.)

Unix then looks at the file and figures out what sort of file it is - that's why the hello.pl script had that first bizarre-looking line. It was a way of communicating to Unix's shell, CGI interpreter or whatever, how to use this file. In the NT world, in contrast, we use file extensions. So take that file with the .cgi extension and rename it to have a .pl extension. Then it'll probably run right - test it by starting your Web browser and pointing it to http://yoursitename.com/scripts/filename.pl, where of course yoursitename.com and filename will vary according to your site and program. The script might run great, or you might see this error:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: 

Too late for "-T" option at C:\scripts\hello.pl line 1. 

To fix this, open up the Perl file and look at the first line, that line that tells Unix how to run Perl. It turns out that IIS will look at that information as well, at least for some of the startup options for Perl. Many Perl scripts start out like this:

#!/usr/local/bin/perl -T 

The -T is the thing that's making this choke. Delete it and save the file, then try re-running it.

Where Do Scripts Go?

I told you to put the scripts in c:\inetpub\scripts, but that's just the default value. There's nothing magic about that directory or indeed about any directory containing scripts; if you wanted to, you could put them in wwwroot. But we don't, for a few reasons.

First, you probably don't want people seeing your scripts. The actual Perl code might have taken you quite a while to write, and you might not want it easily downloaded and stolen. But how do you keep that from happening, given that every browser includes "save as" in its File menu? With two steps:

So we'll need a directory for scripts. That's easy enough to accomplish. First, create a directory on your IIS server, preferably one not under wwwroot. Put the scripts in there. (I'll put it in c:\scripts for this example.) Then, start up the IIS snap-in in Start/Programs/Administrative Tools/Internet Services Manager, and locate the Web site that you're going to add a script directory for. For this example, just add one to your "Default Web Site." Right-click the site and choose New, then "Virtual Directory." That kicks off a wizard; click Next to get past the opening screen, and then you'll see a wizard panel asking you to create an alias; this is the name that people will use to try to access things in this directory.  For example's sake, set the alias to "myscripts."

So you could then put a script, like hello.pl for example, into c:\scripts, and someone out on the Web could then run hello.pl. He or she wouldn't point the browser to www.yourdomain.com/hello.pl or www.yourdomain.com/scripts/hello.pl, even though the directory's name is scripts. The notion of an alias means that the Web visitor would point the browser to www.yourdomain.com/myscripts/hello.pl. Click Next and the wizard will ask you where the actual directory is, and you'd fill in c:\scripts if you were following my example. Click Next to see a dialog labeled "Access Permissions."  Now, this is important, because it'll be different than what you might already know if you're currently an ASP expert.  (You don't have to be an ASP expert to follow this, however.). If you were going to put ASP scripts into my script directory, then you'd check boxes labeled "Read" and "Run Scripts."  But for Perl scripts, un-check "Run scripts (such as ASP)" and check "Execute (such as ISAPI applications or CGI." Click Next and you're done.

Another Example:  Installing Kruse's Calendar

Before leaving this topic, let's try downloading and installing something more substantial than the hello.pl script; try installing Matt Kruse's free calendar script.  First download it from the URL above.

It is a ZIP file, so unzip it to your \inetpub\scripts directory or wherever you're putting scripts.  (I'll use \inetpub\scripts for my example.)  Once you do that, you'll end up with a folder \inetpub\scripts\calendar that contains some of the files for the Calendar app, and another folder \inetpub\scripts\calendar\templates that contain the rest of the files.  In \inetpub\scripts\calendar you'll find a file named calendar.pl, which is the calendaring program, and an administrative program calendar_admin.pl which lets you adjust the calendaring program's behavior.  (There's no need to convert the files to NT/Windows text format, they're already in that format.)  Invoke the calendar from a Web browser by typing http://yourservername.yourdomainname.com/scripts/calendar/calendar.pl.  Have some fun with it, and then go visit www.cgi-resources.com to find lots more Perl scripts.

I like Matt's free script.  You should be able to run it on an IIS 4.0 or Personal Web Server as well, although I've not tried it there.  Remember that if you're connected to the Web constantly via cable modem or DSL that you can set up a Web server on your Web-connected home PC and then access your calendar from anywhere even if you haven't registered a DNS domain name (which can be a pain if you're DSL or cable-connected.)  Just use the IP address of your computer when accessing the calendar, as in (for example) http://63.44.99.18/scripts/calendar/calendar.pl, presuming that your IP address was 63.44.99.18.

Conferences

If you can't attend a class then consider attending one of these conferences:

TechMentor Orlando 6-8 February 2001

I've greatly enjoyed both of the TechMentor shows that I've attended -- there are some great speakers (and no, I don't mean me) and a really good crowd.  I've often found that the attendees are a better source of advice than the speakers in some cases.  They've asked me to do a general session called "The Best and Worst of Windows 2000," and it's a fun talk where you'll learn some undocumented stuff as well as hearing some gripes about Win2K -- but all with a smile, of course.  They've got me slated to do a talk on group policies, as well as new talk on automated rollouts called "Unattended Installations ... With Style."  Check it out at www.techmentorevents.com.

Spring Comdex Chicago 3-5 April 2001

My buddy George Spalding and I had such a great time in Comdex Vegas that we're doing it again in Chicago for Spring Comdex. Get the skinny on 2000 (and Whistler!) from George, me, and some great speakers including my co-authors Christa Anderson and Doug Toombs. Info at www.comdex.com.

WinConnections in Monterey May 8-11

The same folks that brought WinConnections 2000 twice in Arizona last year are returning but this time in Monterey.  I'm doing a general session as well as a variety of other topics.  Find out more at www.winconnections.com.

InterWorks 2001 in San Francisco May 6

The Interex guys, the people who put on HP World, have hired me to do an all-day pre-conference tutorial in San Francisco on Sunday, May 6 on the topic of Active Directory at their InterWorks 2001 conference.  Information at http://www.interex.org/conference/iworks2001/index.html.

Bring Mark to your site to teach

I'm keeping busy doing Windows 2000 seminars, but I've still got time to visit your firm  In just two days, I'll make your current NT techies into 2000 techies.  Find out more at www.minasi.com/w2koutln.htm, mail Jennifer Williams at jennifer@minasi.com, or call her at (757) 426-1431 (between 1 and 5 Eastern time, weekdays, please).

Until Next Month...

Have a great January, keep warm (unless you're one of those lucky dogs in Southern California, where they seem to be having some of the best weather they've had in a while) and go have some fun. Please share this newsletter; I'd like very much to expand this newsletter into a useful source of NT/2000 information.  Please forward it to any associates who might find it helpful, and accept my thanks.  We are now at more than six thousand subscribers (and no, I don't have that many relatives, so I remain amazed that I've got that many readers) and I aim to use this to get information to every single Mastering NT and 2000 Server reader. Thanks for letting me visit with you, and take care!  Many, many thanks to the readers who have mailed me to offer suggestions, errata, and those kind reviews.  As always, I'm at help@minasi.com.

To subscribe, visit http://www.minasi.com/nwsreg.htm. To unsubscribe, link to http://www.minasi.com/unsubs.htm. Visit the Archives at http://www.minasi.com/archive.htm.

All contents copyright 2001 Mark Minasi. You are encouraged to quote this material, SO LONG as you include this entire document; thanks.