Archive for the ‘Non-Unix Shell’ Category

Z Shell

Saturday, May 8th, 2010

The Z shell (zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting. Zsh can be thought of as an extended bourne shell with a large number of improvements, including some of the most useful features of bash, ksh, and tcsh.

The first version of zsh was written by Paul Falstad in 1990 when he was a student at Princeton University. The name zsh derives from Zhong Shao, then a teaching assistant at Princeton University. Paul Falstad thought that Shao’s login name, “zsh”, was a good name for a shell.

Features of note include:
Programmable command line completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands
Sharing of command history among all running shells
Extended file globbing allows file specification without needing to run an external program such as find
Improved variable/array handling
Editing of multi-line commands in a single buffer
Spelling correction
Various compatibility modes, e.g. zsh can pretend to be a Bourne shell when run as /bin/sh
Themeable prompts, including the ability to put prompt information on the right side of the screen and have it auto-hide when typing a long command
Fully customizable
Attesting to the sheer size of this shell is the first sentence of the shell’s manual page, which reads “Because zsh contains many features, the zsh manual has been split into a number of sections”, and then goes on to list thirteen items.

Windows Shell

Saturday, May 8th, 2010

Windows Shell is the most visible aspect of the Microsoft Windows line of operating systems. The shell is the container inside of which the entire user interface is presented, including the Task bar, the Desktop, Windows Explorer, as well as many of the dialog boxes and interface controls, but also describes the past shells, like MS-DOS Executive and Program Manager.

The default Windows shell is called Explorer (confusingly, the same as the MS file browser) ? this is the program that determines the look of your desktop, i.e. it creates the task bar, system tray, start menu etc.

Windows 1 and 2 – Early UI
Just after the PC hit the market (August 1981), a project named “Interface Manager” started. It was renamed to “Windows” because the programmers talked very much about the zones called “windows” on the screen. Rowland Hanson, the head of marketing at Microsoft, convinced the company that the name Windows would be a more appealing name to consumers. The first Windows pre-version was presented in November 1983. It used Word for DOS-like menus at the bottom of the screen. The 1.0 version (it was numbered 1.01; it is rumored that version 1.00 was actually released but quickly pulled due to a severe flaw), released in November 1985, used pull-down menus like the early Macintosh System 1.x (Microsoft actually licensed GUI elements from Apple). The shell was a file manager (not a program manager) called “MS-DOS Executive”. Applications could be launched from the MS-DOS Executive which minimized itself. The minimizing (called “iconing”) was done by transforming the windows into an icon which was placed at the bottom of the screen, in a special minimized windows zone. The maximizing (called “zooming”) could extend the window over the minimized windows zone. Windows could not be overlapped, but they were instead “tiled”. As a result, two windows could not be “zoomed” at the same time.

Windows 2.0 was an interface-based release. The new window controls were introduced with this release, with the new “minimize” and “maximize” terminology. Windows could be overlapped and the minimized window icons could be moved freely on the desktop.

OS/2 1.x
As of version 1.1, launched in 1988, the new OS/2 operating system from IBM introduced a new GUI, called the Presentation Manager. The default shell (a program) was a program manager (not a file manager like in Windows 1.x and 2.x) called “Start Programs”. Versions 1.2 and 1.3 renamed “Start Programs” to “Desktop Manager”, added 16-colour icons support and many more.

Windows 3.x, NT 3.x – The First Revolution
Windows 3.0, introduced in May 1990, inherited the OS/2 GUI. The new “Program Manager” was a simple “front end” where the “groups” and icons had no relation to the actual file system. A background could be put on the desktop, and the window controls were redesigned. The buttons were all in 3-D appearance (the windows weren’t). As a result, the Windows 3.0 operating environment was a success. Later versions of Windows 3.x introduced Screen Savers.

The new operating system from Microsoft, “Windows NT”, featured the same GUI in the first version (3.1), like Windows 3.1x.

Windows 95C, 98 – “Nashville”
The growing popularity of the World Wide Web forced Microsoft to release its own browser, dubbed “Internet Explorer” which was based on technology licensed from Spyglass. In early 1996, Netscape announced that the next release of its browser, Netscape, would completely integrate with Windows and add a new shell, codenamed “Constellation”. Microsoft started working on a similar Internet Explorer release, codenamed “Nashville”. Internet Explorer 4.0 was redesigned and resulted in two products: the standalone IE4 which replaced the Windows shell with a new “Active Desktop” shell and the future Windows releases, like Windows 95C and Windows 98, which integrated Internet Explorer and Active Desktop in the shell.

Windows PowerShell

Saturday, May 8th, 2010

Windows PowerShell, previously Microsoft Shell or MSH (codenamed Monad) is an extensible command line interface (CLI) shell and scripting language product developed by Microsoft. The product is based on object-oriented programming and version 2.0 of the Microsoft .NET Framework. It is available for Windows XP, Windows Server 2003 and Windows Vista and planned for inclusion with Windows Server 2008.

Windows PowerShell is the foundation of the administrative tools for Exchange Server 2007, System Center Virtual Machine Manager 2007 and System Center Operations Manager 2007 where everything is done via command line interfaces and the administrative GUI is layered on top of those commands.

Every released version of Microsoft DOS and Microsoft Windows for personal computers has featured a command line interface tool. These have been COMMAND.COM (in installations relying on MS-DOS) and cmd.exe (in Windows NT-based installations). These were not always capable of reproducing or automating all of the administrative functions available in the graphical user interface (GUI). This has been due to limitations within the command-line equivalents or to Microsoft not providing full fidelity command-line equivalents, although under Windows Server 2003, this situation was improved. Users have also been hindered by a lack of adequate documentation of command-line functionality.

Microsoft attempted to address some of these shortcomings by introducing the Windows Script Host in 1998 with Windows 98. The Windows Script Host was a new scripting layer which could implement a variety of scripting languages. However, the Script Host had its own deficiencies. It was not integrated with the shell, its documentation was not very accessible, and it quickly gained a reputation as a system vulnerability after several high-profile computer viruses exploited substantial weaknesses in its security provisions.

Windows Server 2003 and certain versions of Windows XP included a command-line-based script host called CScript.exe (essentially just a portion of the Windows Script Host introduced earlier), but it was not integrated into the existing shell (cmd.exe). These operating systems provided other ad hoc CLIs as well (netsh, for example), which were not fully integrated either.

By 2003 Microsoft had started to develop a new shell called Monad (aka MSH), a new extensible command shell with a fresh design which would be capable of automating a full range of core administrative tasks.

Microsoft published the first Monad public beta release on June 17, 2005, Beta 2 on September 11, 2005 and Beta 3 on January 10, 2006.

Microsoft announced on April 25, 2006 that Monad was renamed to Windows PowerShell, positioning it as a significant part of their management technology offerings. Release Candidate 1 of PowerShell was released at the same time.

Release Candidate 2 of PowerShell was released September 26, 2006.

Windows PowerShell v1.0 was released to web (RTW) November 14, 2006.

PowerShell for Vista was released on January 30, 2007.

Microsoft has committed to building future GUI tools on top of PowerShell, ensuring that the core administrative functionality remains scriptable. Exchange Server 2007’s management user interface, for example, is built on top of PowerShell. In most everyday tasks, PowerShell can be used in place of CMD.EXE and Windows Script Host (WSH). However, for backward-compatibility purposes both CMD.EXE and WSH will continue to be supported by Windows.

Central concepts
PowerShell’s codename, Monad, comes from Gottfried Leibniz’s monadology, a philosophy in which the universe is a composite of fundamental elements called monads that are integrated in a “pre-established harmony”. Similarly, PowerShell is a composite of the complex tasks of a series of components. The components are special programs called cmdlets (pronounced command lets), which are .NET classes designed to use the features of the environment. The key difference between the usual UNIX approach and the PowerShell one is that rather than creating a “pipeline” based on textual input and output, PowerShell passes data between the various cmdlets as objects (structured data).

If accessed individually from the command line, a cmdlet’s output will automatically be converted into text, but if its output is to be used by another cmdlet, it will be converted into whatever form of object is most appropriate for that cmdlet’s input. This has the advantage of eliminating the need for the many text-processing utilities which are common in UNIX pipelines, such as grep and awk, as well as allowing things to be combined interactively, or in a scripting environment, which would otherwise require a more complex programming language. For instance, a listing of processes will consist not of text describing them, but objects representing them, so that methods can be called on those objects without explicit reference to any outside structure or library.

The first version contains the following features:

A C#-like scripting language with support for hash tables, switch statements which can test on regular expressions, array slicing and anonymous methods (script blocks) which can be stored as data and then later executed. It also provides looping (for/foreach/while), conditional statements (if/switch), variable scoping (global/script/local) and the ability to define functions.
Cmdlets inherit certain options, allowing the user to choose things such as the level of interaction and how to deal with errors. Cmdlets which produce side effects support the options -WhatIf and -Confirm. -WhatIf informs the user what would have happened, but no action takes place. -Confirm informs the user what is about to happen and allows the user to control whether it takes place or not.
One option for dealing with errors is to invoke a “suspend” feature which allows the user to enter a new command shell, investigate a problem, and resume the original command. The user can define the prompts to be shown in such circumstances.
An extensible provider model allows access to and manipulation of the file system and other hierarchical data stores. Some examples: PowerShell comes with a registry provider which allows access to the registry via the “HKLM” and “HKCU” hives; with this, the registry can be browsed by executing commands like dir HKLM:\SOFTWARE\Microsoft at the shell prompt. PowerShell comes with providers for the certificate store, the environment, and shell functions and aliases. Like cmdlets, the provider model is extensible, allowing third parties to create their own provider model and plug it into PowerShell.
A concept called “execution policies” which allows coarse security constraints to be imposed upon PowerShell script execution. Execution policies define the restrictions under which PowerShell loads configuration files and runs scripts. The four execution policies are Restricted, AllSigned, RemoteSigned, and Unrestricted.
Support for the use of script signing to verify the identity of a script publisher and to validate the integrity of a published script using digital signatures.
The command-line options are generally whole words, but can be specified as the minimum number of letters necessary to disambiguate. For example, the option -show-detailed-information could be entered as -s if no other option begins with ‘s’.
Comprehensive, user-extensible tab completion features. The cmd.exe shell in current versions of Windows can only complete file or directory names, in contrast to the advanced completion in shells such as bash and zsh.
The ability to assign the output of a command to a variable, which will then be an object or array of objects inspectable in any way desired.

Stop all processes that begin with the letter “p”:
PS> get-process p* | stop-process
Find the processes that use more than 1000 MB of memory and kill them:
PS> get-process | where { $_.WS -gt 1000MB } | stop-process
Calculate the number of bytes in the files in a directory:
PS> get-childitem | measure-object -property length -sum
Determine whether a specific process is no longer running:
PS> $processToWatch = get-process notepad
PS> $processToWatch.WaitForExit()
Change the case of a string from lower to upper:
PS> “hello, world!”.ToUpper()
Insert the string “ABC” after the first character in the word “string” to have the result “sABCtring”:
PS> “string”.Insert(1, “ABC”)
Download a specific RSS feed and show the titles of the 8 most recent entries:
PS> $rssUrl = “”
PS> $blog = [xml](new-object System.Net.WebClient).DownloadString($rssUrl)
PS> $ | select title -first 8
Sets $UserProfile to the value of the UserProfile environment variable
PS> $UserProfile = $env:UserProfile

File extensions
PS1 – Windows PowerShell shell script
PS1XML – Windows PowerShell format and type definitions
PSC1 – Windows PowerShell console file

List of Microsoft projects using PowerShell
Exchange 2007
System Center Operations Manager 2007 (SCOM 2007)
System Center Virtual Machine Manager 2007 (VMM)
System Center Data Protection Manager 2007 (DPM)
Microsoft Transporter Suite for Lotus Domino
Windows Compute Cluster Tool Pack
Windows Server 2008