This & That
Info To Go
by Karen Bemowski, firstname.lastname@example.org
More About How to Get Started Writing Scripts
If you read "How to Get Started Writing Scripts" (http://www.windowsitpro.com/Windows/Article/ArticleID/50486/50486.html) last month, you know about some resources that you can use to learn how to write Windows shell, VBScript, and Windows PowerShell code. As with chocolate and potato chips, getting just a taste of learning makes you hungry for more. So, I want to cover resources that you can use to learn how to write JScript, Perl, and T-SQL code.
Like VBScript, JScript is a scripting language associated with Windows Script Host (WSH), an environment for executing scripts. Consequently, you might expect to see some WSH references in a list of JScript resources. However, that's not the case. Most WSH resources don't include information about JScript. For example, Tim Hill's Windows Script Host (New Riders Publishing, 2003) is highly recommended for learning WSH and VBScript but doesn't include any information helpful in learning JScript. Surprisingly, even the Windows scripting bible--Windows 2000 Scripting Guide (Microsoft Press, 2003)--contains no information about JScript.
If you run into problems learning JScript, you can talk with fellow scripters at Windows IT Pro's Scripting forum (http://forums.windowsitpro.com). This forum covers all types of scripting languages, so it's a good Web site to bookmark in your browser.
Perl is one of the harder scripting languages to learn. However, it offers some benefits, such as being able to run your scripts not only on Windows platforms but also on other platforms, such as Linux and Macintosh. The "PERL: The Practical Extraction & Reporting Language" Web page at http://www.roth.net/perl discusses some other benefits of using Perl. This Web page also has a link to the ActiveState Web site, which offers a free, ready-to-install distribution of Perl called ActivePerl. One of the most popular Perl distributions, ActivePerl includes not only the core Perl engine but also some popular Perl modules and the Perl Package Manager (PPM) for installing Comprehensive Perl Archive Network (CPAN) modules.
If you're a Perl newbie, you might be wondering what modules are. Perl modules are reusable software components that offer specific functionality. For example, the Win32::Perms module lets you modify permissions on files, directories, registry keys, network shares, and shared printers. The only way you can take advantage of a Perl module's functionality is through a Perl script--you can't run modules by themselves. The CPAN Web site (http://www.cpan.org) offers a large collection of Perl modules. The PPM for CPAN lets you install a Perl module from that Web site by typing a simple command.
After you've installed ActivePerl or another Perl distribution, you're ready to learn Perl. The book to start with depends on your background:
After you have a basic understanding of the Perl language, you can focus on areas of interest to you. For Windows systems administrators, two books of interest are
DBAs will want to check out Programming the Perl DBI (O'Reilly, 2000) by Alligator Descartes and Tim Bunce. This book covers the Perl Database Interface (DBI), a Perl-specific interface that provides database functionality.
If you run into problems learning Perl, I suggest visiting some of the many newsgroups and forums in which you can talk with Perl enthusiasts. Besides Windows IT Pro's Scripting forum, you can check out the forums and newsgroups listed on the Win32 Perl Links Web page at http://www.roth.net/perl/links.
T-SQL is the built-in scripting language of Microsoft SQL Server. T-SQL underwent some major changes in SQL Server 2005, so if you want to learn this scripting language, it's best to learn the 2005 version. One recently released book that might help you do so is Beginning Transact-SQL With SQL Server 2000 and 2005 (Wrox Press, 2005) by Paul Turley and Dan Wood. None of the scripting experts I talked with are familiar with this book, but it received an average rating of 4 stars on Amazon.com. Another resource is SQL Server 2005 Books Online (BOL). You can download this BOL for free at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx.
Because T-SQL is based on SQL, learning about SQL can be helpful. To get a background on SQL, you can check out Robert Sheldon's SQL: A Beginner's Guide, 2nd ed. (McGraw-Hill Osborne Media, 2003).
If you run into problems learning T-SQL, you can ask questions on SQL Server Magazine's T-SQL forum at http://sqlforums.windowsitpro.com. For a list of T-SQL newsgroups and Web sites, go to http://www.insidetsql.com/resources.htm.
This list of JScript, Perl, and T-SQL resources isn't all-inclusive. If you've come across any other helpful resources, please let me know and I'll add them to the list.
This & That
Hey, Congratulations Scripting Guys!
On July 21, Microsoft will publish the 500th "Hey, Scripting Guy!" article. To mark this monumental milestone, Microsoft is featuring a sweepstakes, a postcard contest, and daily comic scripts (don't expect to laugh too much, though). To join the celebration, go to the Microsoft Script Center (http://www.microsoft.com/technet/scriptcenter/default.mspx). By the way, if you ever wondered who the scripting guys really are, check out the Web page at http://www.microsoft.com/technet/scriptcenter/sgwho.mspx.
UNIX Administrators Won't Be Laughing Anymore
Windows scripting has long been the butt of jokes from UNIX system administrators mainly because Windows has been lacking many key features that make scripting truly useful. However, Microsoft is now not only catching up to but actually surpassing other OSs' scripting capabilities with its new Windows PowerShell scripting environment. Formerly code-named Monad, PowerShell delivers several scripting capabilities that Windows has never had and greatly improves some existing features. Learn how PowerShell is filling in the capability gaps in the article "Introducing Windows PowerShell," which will be featured in the August issue of Windows IT Pro.
If I Only Had an IIf Function
VBScript enthusiasts no longer have to wish for an IIf function. Short for Immediate If, IIf is a simple but helpful function that's native to Visual Basic for Applications (VBA) but non-existent in VBScript. However, with some simple creative coding, you can create a VBScript function that has the same functionality.
The IIf function evaluates an expression and returns a specific value, depending on whether the expression evaluates to True or False. Thus, you can use the IIf function in place of VBScript's If...Then...Else statement.
The IIf function contains only three lines of code:
Function IIf(expr, truepart, falsepart) If expr Then IIf = truepart Else IIf = falsepart End function
You place this function in your script, then call the function, following the syntax
IIf(expr, truepart, falsepart)
where expr is the expression you want to evaluate, truepart is the value or expression returned if expr is True, and falsepart is the value or expression returned if expr is False. For example, the calling code might look like
returnValue = IIf(A = B, "A equals B", "A is not equal to B")
If the value of what is stored in variable A equals the value of what's stored in variable B, then returnValue would contain the string "A equals B". Otherwise, returnValue would contain the string "A is not equal to B".
You can use just about any type of expression in the IIf function. Similarly, the function can return just about any type of value (e.g., character, number, date). The expressions in the argument list can include calls to other functions and nested IIf functions. You can even nest IIf within other VBScript functions.
Thanks to Jim Turner for writing and sharing his VBScript IIf function.
Info To Go
Save $80 Off the Windows Scripting Solutions Newsletter
Get endless scripting techniques and expert-reviewed code. Subscribe to Windows Scripting Solutions today and save $80:
Discounted Offer for the Windows IT Pro Master CD
Save 50% off the Windows IT Pro Master CD! Order now and get portable, high-speed access to the entire Windows IT Pro article database on CD--a searchable library that includes every issue ever published. The newest issue also includes BONUS Windows IT Tips. Order now and save 50%:
Achieve compliance in today's complex regulatory environment while managing threats to the inward- and outward-bound communications vital to your business. Adopt a best-practices approach, such as the one outlined in the international information security standard ISO/IEC 17799:2005. Download the white paper today and secure the confidentiality, availability and integrity of your corporate information!
Are you protected company-wide against spyware, keyloggers, adware, and backdoor Trojans? Test the state of the art scanning engine that uses threat signatures from multiple sources to track down the culprits that antivirus solutions alone can't protect you against. Download your free 30 day trial of CounterSpy Enterprise today!
Learn how a database utility for SQL Server can lower operational costs, simplify management, and increase the availability of your SQL Server deployment. Live event: Tuesday, June 20
Take an up-to-date look at secure, remote access to corporate applications and stay ahead of the curve when making decisions about near- and long-term IT infrastructure. On-demand Web seminar.
Gain control of your messaging data--and make your job easier--with these step-by-step instructions for complying with the law and ensuring your systems are working properly.
Learn how to gather evidence of compliance across multiple systems and link the data to regulatory and framework control objectives. View this on-demand Web seminar today!
This email newsletter is brought to you by Windows IT Pro, the leading publication for IT professionals deploying Windows and related technologies. Subscribe today!
Windows IT Pro is a division of Penton Media, Inc. 221 East 29th Street, Loveland, CO 80538, Attention: Customer Service Department
Copyright 2006, Penton Media, Inc. All Rights Reserved.