“Once upon a time, when DOS walked the earth, the command line was the primary user interface for most of our computers. Then, Windows came along, and Microsoft seemed set on leaving the command prompt to dry up and wither into obscurity. Fortunately, Microsoft has again turned its attention to the command line and, in so doing, has produced one of the most compelling new Windows features eWEEK Labs has ever had the pleasure to test: Windows PowerShell.”
Nonsense. Why to learn another shell. Bash html user`s guide got 1.5MB . Consider http://www.cygwin.com/ .
BTW when DOS walked the earth Richard M. Stallman founded http://www.fsf.org/ as an answer to the “most compelling new MS features”.
why in the world would someone want to learn bash, one of the most unintuitive shells ever created.
Having said that, powershell also seems to be behind the times in its anachronistic cmd.exe like UI
Bash is at once a shell interpreter (in its compiled form) and also a language. I think it doesn’t really make sense to call a language unintuitive. Whether or not a language is intuitive is determined by the user’s familiarity with similar languages, etc.
I believe that bash is very intuitive if you’re fluent in ksh, for example. However, if you’ve never used a shell then it is not intuitive at all. Likewise, if you grew up using VBScript, bash is not intuitive (but the inverse is also very true).
Once you learn how to pipe together commands and the unix shell way of thinking, I think working in bash is very intuitive. I routinely pipe text through sed, awk, cut, tac… I construct lists of files with find, iterate over them in bash for loops or with xargs.
I like the extensions that GNU added to bash over plain old sh, and when I’m working in ksh on an AIX system, I miss all the power of gnu readline and bash’s special variables and keybindings like $! or !cmd:p, etc.
Some people will tell you that bash is bloated, and I often will write a shell script so it does not NEED bash and can run on something leaner like ash or dash, but for an interactive shell bash cannot be beat. bash is the best interactive command line tool that exists today for shell work, period.
Some people will tell you that bash is bloated, and I often will write a shell script so it does not NEED bash and can run on something leaner like ash or dash, but for an interactive shell bash cannot be beat. bash is the best interactive command line tool that exists today for shell work, period.
I beg to differ. ZSH is the best shell.
“but for an interactive shell bash cannot be beat. bash is the best interactive command line tool that exists today for shell work, period.”
Fish (Friendly Interactive SHell: http://roo.no-ip.org/fish/ ) is a really nice attempt to build user friendly command line (especially for novice users) and polish some Bash rough edges.
Just from what you wrote:
sed, awk, tac…xargs…keybindings like $! or !cmd:p
can you really say any of this makes sense in any language known to man?
And piping isn’t just for unix. VMS DCL also has pipes (ok and also lots of $’s) . But it was designed for the most part to be consistent, syntax checking and “user-friendly” and I don’t mean gui clicky grandma user-friendly.
“can you really say any of this makes sense in any language known to man?”
And you think your grandmother can make sense of a line that looks like “get-childitem | measure-object -property length -sum”? Face it: to the average user, it doesn’t matter what language you use, they’re all just magical gibberish.
I read a few guides on unix shell programming an within a day or two I was able to write useful shell scripts with the “no sense” sed/awk/xargs/… tools.
Bash, combined with a good terminal emulator, is a joy to use. To execute the previous command I just hit ‘up’ and ‘enter’. Can’t do that in DOS – 4 out of 5 times it gives you the wrong command. I just can’t figure out how command history in DOS works, nor do I care about how it actually works – it doesn’t work well and that’s all that matters. Does PowerShell fix that?
Tab completion in bash is easy to use. I hit tab and it completes the filename, or completes it as much as possible and presents you with possible choices. In DOS, it completes to the first match and doesn’t show you all possible matches, which is stupid. I have to press Tab several times to get the filename I want. Does PowerShell fix that?
In a proper Unix terminal emulator, I can have multiple terminals in one window, seperated by tabs. I can easily navigate between the terminals with Ctrl-PageUp/PageDown, and they don’t clutter the task bar. Furthermore, most X window managers can snap a window to the edge of another window or the edge of the screen, making it extremely easy to organize your terminal windows. DOS can’t do any of that. Does PowerShell fix that?
People are all talking about how awesome PowerShell is because it uses .NET objects and what not, but frankly it doesn’t seem very usable as an *interactive user program*. People talk about PowerShell being a “shell” but it looks more like a scripting language to me. If I want to do more complex things that I can’t do easily in bash I’ll launch Perl.
Bash, combined with a good terminal emulator, is a joy to use. To execute the previous command I just hit ‘up’ and ‘enter’. Can’t do that in DOS – 4 out of 5 times it gives you the wrong command.
That’s why many experienced DOS users use 4DOS, why many experienced OS/2 CLI users use 4OS2, and why many experienced Windows CLI users use either 4DOS, 4NT, or both.
The vanilla shell sucks on those platforms, but replacing it is trivial.
Edited 2007-01-25 16:41
can you really say any of this makes sense in any language known to man?
Bash is a programing language known to man. Therefore, the answer to your question is, simply, yes.
why in the world would someone want to learn bash, one of the most unintuitive shells ever created.
Hmmm. I may be wrong, but I’m drawing the conclusion from statement that you tried to learn it, found it difficult and gave up. Now, you don’t think anyone should spend the time learning it.
Now, assuming that I’m wrong and have misinterpreted your comment, when you say most unintuitive shells, I’m assuming you’ve tried others and found them more intuitive. What shells would those be?
ok I’ll give an example of unintuitiveness.
let’s say you want to delete all files with extension .txt and you type this
rm * .txt
oops forgot I added a space
oops thanks for not telling me I will wipe out all the files and just do it anyway.
Powershell requires confirmation
Edited 2007-01-25 05:12
ok I’ll give an example
let’s say you want to delete all files with extension .txt and you type this
rm * .txt
oops forgot I added a space
oops thanks for not telling me I will wipe out all the files and just do it anyway.
Powershell requires confirmation
If you’re that careless then turn interactive mode on. Problem solved.
ok I’ll give an example of unintuitiveness.
let’s say you want to delete all files with extension .txt and you type this
rm * .txt
oops forgot I added a space
oops thanks for not telling me I will wipe out all the files and just do it anyway.
Powershell requires confirmation
well… just add
alias rm ‘rm -i’
to your .login file or .cshrc (depending on your shell)
problem solved – confirmation for every deletion
I think it’s a REALLY BAD idea to alias rm to “rm -i”. Not because I’m implacably opposed to interactive deletion (i’m not) but because (a) it might screw up scripts which rely on rm NOT being interactive to work properly; and (b) what happens when you move to the machine of someone who has NOT aliased rm to “rm -i”?
Far better to alias “rmi”to “rm -i” “mvi”to “mv -i” etc, and use those instead. Then when you use a system that uses the default behaviour for “rm” and doesn’t have those aliases, it’ll say “rmi… not found.”
(a) it might screw up scripts which rely on rm NOT being interactive to work properly
Or you fix those broken scripts…
What about people who don’t know how to write scripts and are only using the scripts provided by the distro?
File bugreport.
Seriously, if the distro ships scripts that broken, they shouldn’t be using the distro in the first place.
I think we’re at cross-purposes here; whilst I know there are distros that alias rm to “rm -i”, I’m speaking specifically of cases where the USER aliases commands. A distro isn’t going to want to change a script just to satisfy one user, and since scripts are written to be non-interactive, there’s no reason why they shouldn’t rely on a non-interactive “rm”.
Thats why proper scripts should user rm -f to explicilty don’t rely on whether rm is interactive or not.
‘Thats why proper scripts should user rm -f to explicilty don’t rely on whether rm is interactive or not.’
Not.
-i overrides -f, so rm -f with alias rm=’rm -i’ is the same thing as rm -i.
In my scripts, I use [backslash]rm or /bin/rm, to make sure the alias won’t be used.
Edited 2007-01-25 16:35
I stand corrected
Not.
-i overrides -f, so rm -f with alias rm=’rm -i’ is the same thing as rm -i.
In my scripts, I use [backslash]rm or /bin/rm, to make sure the alias won’t be used
OMG !!! Are you guys all there to push people to mistakes or what ?
This basically depends on the shell. And as a matter of fact, the bash shell, even in sh (meaning ksh) emulation, overrides -i if you use -f.
So your alias WILL be overrided by any “rm -f”.
Anyway, this is just plain useless (and even unwanted, sometimes dangerous), as just putting “#! /bin/sh” at the start of your shell means you won’t load any alias other than the ones in your script.
‘OMG !!! Are you guys all there to push people to mistakes or what ? ‘
Don’t get excited, boy…
BTW, just checked on a solaris box, and you are right. The [backslash]rm seems to be only necessary when you are typing the command.
But the ‘-f’ switch doesn’t seem to be necessary either.
I think you and the people that don’t understand a thing about shells (all those that modded you up basically) should STFU and go right away learn to use a shell, and stop pretending you do.
Because your stupid rant about “rm -i’ alias that can have impact on a script is just plain BS.
An alias on “rm -i” will just not impact any of your scripts, unless you explicitely make them login scripts, which is plain stupid if it’s not your session script.
You’re basically complete newbies on shells, which surely explains all the stupid comments about monad being anything good for administration.
FYI, your mistake here is typically how people manage to render their system unusable with a “rm -r *”, because they think that having defined rm as “rm -i” somewhere, and it works in their interactive shell, means it will work in their script, and prevent any mistake.
And I hope you actually never went to other people machines to “fix” them, because with your poor knwoledge of shells, you’ll just break everything.
Asking what happens when you go to a machine that has not aliased rm to “rm -i” is even more scary. “unalias rm” followed by “alias rm=’rm -i'” is sth you should at least understand to help others. Even worse, a simple ”
m” instead of “rm” will just bypass any alias you put on “rm”, and it works for every command.
You’re just an example of people that, instead of asking why everyone does sth this way, just assumes you’re better than them all, thinks they’re all wrong and you’re right, and go implement a really poorer solution. And the monad just seems like that to me, too, a unix shell with all the mistakes embedded.
Well, thanks for that insulting and generally incomprehensible (because of a 3-year old’s understanding of punctuation) rant. Remind me to mod you down someday.
(sh/bash)
alias rm=’rm -i’
(csh/tcsh)
alias rm rm -i
Bash is not unintuitive. It is powerful and demands that you respect that power. For example, you could easily implement a “Trash” mechanism in Bash so if you did type that command, your files would be easily retrievable.
I HATE the idea of a shell asking me if I’m sure every time I type a command.
I did something similar some time ago, but it was a chown -R in the /etc directory…
It was solely my fault and I’m only blaming myself because I didn’t double-check what I was typing and where.
And, btw, with confirmations for every single deletion, sooner or later you’ll switch to the “hit enter without reading” side, and the advantages of the confirmations are gone.
Its the only reason to upgrade from XP
Why? Powershell runs fine on XP, and has for quite some time.
Its the only reason to upgrade from XP
Not really. PowerShell 1.0 was RTM’ed for XP a couple months ago. I’ve had it installed since then. It’s available here:
http://www.microsoft.com/windowsserver2003/technologies/management/…
The Vista version is also available at the same location, but it’s still at RC2 (RTM is “expected” for Jan 31.)
DOes anyone else see this as a bit complicated for a shell?
Yeah, it reads to be very complicated, i found myself thinking why not just use cygwin whilst reading the article. To be honest i lost interest when
“When you pipe the output of this cmdlet, called Get-ChildItem, to the cmdlet Sort-Object,”
was mentioned, MS should just cut to the chase and impliment a proper unix (like?) shell without all the seemingly BS layers like what was written. Who needs the shell to work magic for us when the tried and tested
ls -lrt
can do what we need, without all the leg bone connects to the knee bone crud …
man ls and man sort are your friends …. ohh sorry i assume not with this tool, for this its probably, start –> help –> search for text –> “powershell sort by file size”
I tend to agree with you. To me, the basic DOS syntax gets me by. Don’t get me wrong, I like Unix shells like bash and csh much better. But, I don’t get annoyed as much having to type copy instead of cp or dir instead of ls. I can live with that. But, if I want or need some elaborate OO code, I can use Python or C# or something made for writing powerful applications. What I miss are things associated with basic conveniences like:
o hitting tab twice to show more suggestions
o tabs on the command window itself
o up arrow history that can filter based on the few characters you type
o history that #1, works and #2 isn’t forgotten between sessions
o includes apps like grep, sort, uniq, cut, sed and awk by default
I should elaborate to say that if MS will just make things less annoying, I will be happy. We have Vista at work. In fact, we have every new MS app at work. And, I have absolutely no interest in installing them. I could, but I’m just not excited by all of the hype.
Edited 2007-01-25 03:42
PowerShell has aliases for lots of unix commands like ls.
That’s cool. Someone else here mentioned that it accepts forward or backward slashes, too. For me, that will be great. I hate having to type backward slashes on MS. For people starting out, they may get very confused as to which way is the right way. But, you can’t blame MS for not switching cold turkey. That would break a lot of things. These are things that I look forward to discovering.
The purpose of the PowerShell is to allow difficult tasks to be easily coded as scripts. It gives access to .NET, and therefore it can be used for programming scripts, .NET applications, and all kinds of difficult to perform tasks.
Then they should have called it PowerScript or MS Visual ADVANCED or something.
But they called it PowerShell and it’s quite shitty at that job. For 40MB of memory out of the box you get a shell that’s overly complicated and less suited for many shell tasks than bash (or even cmd.exe).
It’s great that MS finally made its own Perl/Python/Ruby clone to satisfy their NIH syndrome but in the meanwhile we’re still waiting for a powerful shell for Windows without all the jumping-through-loops involved in using cygwin.
Edited 2007-01-25 15:10
Right on.
I used to be a Beta tester for this thing, and let me tell you, it’s over-complicated. You need to relearn everything you used to know about shells, and I seriously doubt it’s worth the effort. I’ll stick to my tcsh.
Now this idea of an object-oriented shell sounds pretty interesting, but is it going to be useful as the Linux/BSD/whatever command line? Basically, there is a huge console-culture on UNIX and UNIX-alikes, so a vast repertoire of tools is available. Even if you don’t know what kind of tool to use for the job you want to accomplish, when you’re familiar with your system there’s always some kind of paper trail (searching package manager descriptions of software suites, flicking through man pages, etc.) that you can follow to find out what you need to do.
A lot of the usefulness of the shell as I use it on Linux seems to stem from modularity. There really seems to be only a very small amount of built-in functionality, and everything else is added on in nice, self-contained modules. As I understand it, this PowerShell gets a lot of its capability from the .NET libraries, which looks like a fairly monolithic approach to be taking. Will it be as useful with 3rd-party contributions?
I’m not bashing PowerShell (no pun intended), since it seems like it’s something new, and that’s always something to be admired. Also, it’s obviously a very young project, so it would be stupid to write it off already. I’m just curious as to how well it’s going to work. I mean, bash certainly has its weaknesses, but it also has a well-defined place; for the more complicated jobs where a more flexible, possibly object-oriented approach would be favoured, there’s always Ruby or Perl or whatever, right?
“…but is it going to be useful as the Linux/BSD/whatever command line?”
I think it might be, but just as bash would be pretty useless without all the unix commands like find/grep/awk/…, PowerShell will be useless unless it has the same thing (only I think they’re called commandlets in that world).
You need the primitives for listing processes, listing files, printing.
But also, you’ll need to be able to interact with other, non-microsoft programs. You will probably also need to parse plain old text in a way that isn’t totally awkward.
The thing I see as the best thing with PS is readability.
If I can sort by a named attribute instead of a column number, that’s a win. If that attribute knows how it should be sorted then that’s another win.
If you look at the man page for ‘sort’ in your favourite unix you see that you can specify sorting to be alphabetically, numerically, by date and other things.
I don’t know all the options, and if I could sort without having to know them, I’d be happier.
GNU ls -S sorts files by size. You don’t even need a sort command.
And if they prefer, ls -s will print out sizes, so you can pass it to the other side of the pipe… just like (apparently) powershell with its size object.
But, sometimes you want to sort the contents of a logfile or something.
For example,
cat error.log | sort -n +4
I understand that the Mono team will provide a GPL’d equivalent to Monad called “Gonad”. Time to send Miguel and the boys a case of Bawls.
UNIX shells require you to parse text output to get at the data you want. Passing objects around just makes more sense.
As a CLI it’s not bad either. It will take / or as a path separator.
Passing objects around just makes more sense.
I’m not so sure that’s such a great idea. Sure, it makes it a bit less of a mess, but what do you do when you’re trying to pipe to/from a 3rd party program that doesn’t support this object model?
I’m not so sure that’s such a great idea. Sure, it makes it a bit less of a mess, but what do you do when you’re trying to pipe to/from a 3rd party program that doesn’t support this object model?
Serialize the object to text. It’s easy to go from an object to text, but not the other way.
There is a reason we have the notion of structures in programming languages and don’t store everything in strings.
You can represent any in memory data structure as a text stream using some form of markup. XML comes to mind for the more complicated cases. Simple white space works for the more trivial cases.
The last thing that we need is to use XML for passing data between apps in the command line.
Two Reasons.
1) XML in these cases would be self defining (no XSD) thus parsing it in the target application would be a nightmare, unless you want to have a “Generaic ALL Apps XSD”
Which leads me to the second
2) Look at the mess MS in got itself into with Office XML. The spec is 6000+ pages! This sort of bloatware is something we dont need. Then there is the danger of MS making it Namespace enabled and somehow forcing it to go out over the net and do an underhand WGA Check?
Ok, I might be speculating a lot but this is the sort of thing that MS might get up to if they enabled XML as the object passing mechanism in a shell.
Please remember the KISS principal.
XML is not the solution here.
I didn’t say it was a good idea, just that it can be done. I also mentioned white space (line newlines) ;-).
And what happens when windoze in their infinite wisdom changes an object class but doesn’t teach the other cmdlets how to deal with the new properties. Piping works because it’s simple and every Unix/Linux CLI program understands it. This is a typical MS answer for a problem that doesn’t exit.
UNIX shells require you to parse text output to get at the data you want. Passing objects around just makes more sense.
No need for objects, just make commands optionaly accept xml in/output. That way you would have the benefit of both structured output and text based output in both xml and human-output modes. There was actually a project that developed xml-based replacements for common unix commands, but I can no longer find it.
The MS solution seems too over-engineered and buzzword compliant (aah objects) to me.
I’m thinking that “over-engineered” and “buzzword compliant” might also apply to a solution that use xml.
Hmmm. Now, I’m sure passing objects around will come in handy one day. But, generally, I think of a shell as an “interface” not a “scripting language”. So, I’m just more interested in the forward slash backward slash thing than the scripting part. If I need something more powerful than simple bash or dos scripts can handle, I’m thinking about using Python.
the Windows Object Oriented Shell!
(or the sound made by the concept of shells passing over the head of MS)
I wonder how long it’ll be before anyone gets that both the GUI and the CLI have a place in using systems and implements a good unified UI.
Haha
Sorry I can’t mod you up, but heehee
Well I almost didn’t even bother to read this article, but am thankful I did. This actually does sound like a very elegant idea. It seems like a natural evolution to go from everything-is-text to everything-is-an-object. Of course there will still be places where pure text processing is appropriate, but there is no reason such operations can’t be fit into this design.
It has the potential to make scripts more robust, where pipelines aren’t dependent on the order of fields in their input. And things like full tab completion fall out of the design for free.
What I wonder is if the objects that get passed around are mutable? If so, the third command in a pipeline could alter a passed in object (that had been sorted and passed through a selection filter) to update a database, or icon, or endless other possibilities. That would be quite a powerful ability and an advancement over what is offered in any *nix shell today.
How can something that never went away make a comeback?
Sure they whole passing oblects not text thing is a cool theory, but what does the syntax for the language actually look like?
from http://en.wikipedia.org/wiki/Powershell
Calculate the number of bytes in the files in a directory.
In powershell:
get-childitem | measure-object -property length -sum
In bash:
du -h
And it is not like the bash command is cryptic, du = “disk usage”, the -h is not even required but it is the flag for “human readable”, so you don’t get an answer back in KB.
For some more interesting info check out the Powershell sctipts on Technet here: http://www.microsoft.com/technet/scriptcenter/scripts/msh/default.m…
The following script is designed to “List IP4 Route Table Information” (like route -p or netstat -r)
$strComputer = “.”
$colItems = get-wmiobject -class “Win32_IP4RouteTable” -namespace “rootCIMV2” `
-computername $strComputer
foreach ($objItem in $colItems) {
write-host “Age: ” $objItem.Age
write-host “Caption: ” $objItem.Caption
write-host “Description: ” $objItem.Description
write-host “Destination: ” $objItem.Destination
write-host “Information: ” $objItem.Information
write-host “Installation Date: ” $objItem.InstallDate
write-host “Interface Index: ” $objItem.InterfaceIndex
write-host “Mask: ” $objItem.Mask
write-host “Metric 1: ” $objItem.Metric1
write-host “Metric 2: ” $objItem.Metric2
write-host “Metric 3: ” $objItem.Metric3
write-host “Metric 4: ” $objItem.Metric4
write-host “Metric 5: ” $objItem.Metric5
write-host “Name: ” $objItem.Name
write-host “Next Hop: ” $objItem.NextHop
write-host “Protocol: ” $objItem.Protocol
write-host “Status: ” $objItem.Status
write-host “Type: ” $objItem.Type
write-host
}
WOW, they reall made _that_ easier.
In bash:
du -h
And it is not like the bash command is cryptic, du = “disk usage”, the -h is not even required but it is the flag for “human readable”, so you don’t get an answer back in KB.
but diskusage and filesize are 2 different things
This reminds me of Windows Script Host. Why write two lines of Perl when you can write 12 lines of VBScript?
PowerShell seems to be more of a vehicle for .NET adoption than a solution for sys admins.
The ‘Tech Analysis’ and ‘PowerShell’ are neither of what they portend to be.
The tech analysis is no more than an impression. There is no systematic deconstruction, comparison or expression of objective aims in this article.
Like wise the name chosen for monad is boastful and disingenious. What wrong with a normal name such msh ? If as a company you can’t name your products with out the unecessary hype (office/vista); how can we trust it is designed, produced or supported in a sane way.
I suppose it can all be summed up by a peek at dsa.msc and the Exchange System Manager.msc This is more than vindication for the *nix like cli, as PowerShell is probably doomed to cp it poorly. To end on a constructive note, what MS should have done is absorbed cygwin and exposed all its internals (csvde, cacls, services and registry) via *text only*. Then ensured that these methods were available remotely, by default, like it is so easily,securely and conviniently done through ssh on *nix today. None of this 1/2 arsed psexec/dameware/gp based admin insanity we have now.
Powered by PowerShell
http://www.proudlyserving.com/archives/2005/08/alleged_monad_v.html
http://www.computerworld.com/securitytopics/security/holes/story/0,…
I’d say nice try, but it isn’t even that:
http://blogs.msdn.com/powershell/archive/2006/08/03/687838.aspx
But, how long until people start writing viruses and worms using this technology? We all know that MS security is lax, but now a powerful new scripting tool has been added to the mix.
Talk about revisionist history. Apple had a hugely popular GUI based OS more than a decade before Windows-95. And many would argue that Win95, was just a buggy shell for DOS.
Msft didn’t have a half-way worthwhile GUI based OS until 2000 – sixteen years after the Mac.
BTW: I don’t use Mac, never have. I am no Apple fanboy, but this sort of revisionist history is too much.
Don’t forget that Amigas had a “half-way worthwhile GUI based OS” in 1985 – and unlike the Mac it had colour! Also unlike the Mac, it had a pretty worthwhile command line interface – different from Unix, and probably inferior to it, but definitely superior to MS-DOS.
well, I only use (so far)
#dir## /bin/rm -iv
#dir## /bin/rm -rf
(being really really careful sometimes with a
ls beforehand, once deleting /tmp rather than
./tmp )
#dir## /bin/rm -v
(being really REALLY careful with always a ls beforehand)
Here’s a pretty cool Powershell script that I saw at digg:
$v = new-object -com “SAPI.spvoice”
$v.Speak(“Shall we Play a Game?”)
I know it can be done on with other systems, but I didn’t know this could be done with PowerShell until I read about this at digg, and I thought it was cool.
More importantly, it shows PowerShell’s ability to work with COM objects (besides .NET objects), via .NET’s COM interop.
So one could mix and match COM and .NET objects in a script. And one can drive any app that implements OLE Automation.
For example one would instantiate an Excel COM object with:
$o = new-object -com “Excel.Application”
(With VSTO, I think PowerShell might be able to talk with Excel via .NET without using .NET’s COM-interop functionality, but I’m not sure.)
(BTW, VBScriptHost already allowed for driving of automation apps, as do various so-called “scripting languages” like Python, and AppleScript drives apps on Mac OSX (and Cocoa apps automatically get some default scriptability), so no, I’m not claiming a “breakthrough” here, just adding to the discussion.)