Windows PowerShell vs. bash examples - Linux
This is a discussion on Windows PowerShell vs. bash examples - Linux ; On Nov 3, 7:19*pm, Terry Porter wrote:
> [crossposts snipped]
>
> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
> > The claims that PowerShell is better than bash piqued my curiosity, so I
> > decided to ...
-
Re: Windows PowerShell vs. bash examples
On Nov 3, 7:19*pm, Terry Porter wrote:
> [crossposts snipped]
>
> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
> > The claims that PowerShell is better than bash piqued my curiosity, so I
> > decided to check PowerShell out.
>
> > I am bowed to the genius of PowerShell creators.
>
> Thanks Ignoramus22113!
>
> Most informative post indeed, and now I know what *'powershell' really
> is ...
>
His post was pure crap. None of that was powershell. Those were old
vbscripts.
Eric already posted a real powershell example... Do you want more?
--
Tom Shelton
-
Re: Windows PowerShell vs. bash examples
On Mon, 03 Nov 2008 21:31:08 -0800, Tom Shelton wrote:
> His post was pure crap. None of that was powershell. Those were old
> vbscripts.
>
> Eric already posted a real powershell example... Do you want more?
I tried Powershell. Powershell is no BASH. KSH from the mid 90's is
more powerful. BASH actually makes sense ... and is multi-platform.
--
// This is my opinion.
-
Re: Windows PowerShell vs. bash examples
On Mon, 03 Nov 2008 20:26:22 -0600, Terry Porter wrote:
> On Mon, 03 Nov 2008 16:45:33 -0500, Erik Funkenbusch wrote:
>
>> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
>>
>>> The claims that PowerShell is better than bash piqued my curiosity, so
>>> I decided to check PowerShell out.
>>>
>>> I am bowed to the genius of PowerShell creators.
>>>
>>> Here's one example:
>>>
>>> http://www.microsoft.com/technet/scr...es/scriptshop/
> shop0305a.mspx#EHC
>>
>> Uhh.. dude. Are you an idiot?
>>
>> That's wscript, which has been in Windows since IE4. That's not
>> PowerShell.
>>
>> All your examples are wscript examples, not Powershell. What kind of a
>> moron are you? Oh right, you're an Ignoramus.
>
> Please feel free to post a refutation by example to the OPs article ?
>
> Somehow your followup stinks of rotting Wintroll to me ...
I notice you are silent on my followup post where i posted a one-line
example similar to Ignoramus's.
Why is that Terry?
-
Re: Windows PowerShell vs. bash examples
On Mon, 03 Nov 2008 21:37:54 -0600, Ignoramus7766 wrote:
> On 2008-11-04, Paul Hovnanian P.E. wrote:
>> jellybean stonerfish wrote:
>>>
>>> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
>>>
>>> > And here's how you do it with bash:
>>> >
>>> > awk '{print "Use WMI to get OS and SP versions from " $1}' < hosts.txt
>>>
>>> You cheated. You are supposed to do it in bash, not use bash to call
>>> awk.
>>>
>>> sf
>>
>> perl -e 'while(<>) { print "Use WMI to get OS and SP versions from $_"
>> }' < hosts.txt
>>
>
> You can do better than that:
>
> perl -np -e 's/^/Use WMI to get OS and SP versions from /' < hosts.txt
>
> sed 's/^/Use WMI to get OS and SP versions from /' < hosts.txt
So, Ignoramus. I notice you're quite silent on my rebuttal of your post.
Why is that?
-
Re: Windows PowerShell vs. bash examples
In comp.os.linux.misc Ignoramus7766 wrote:
> The whole point of bash is to NOT be a bloated pig like powershell,
Absolutely.
Chris
-
Re: Windows PowerShell vs. bash examples
On Nov 3, 11:01*pm, jebblue wrote:
> On Mon, 03 Nov 2008 21:31:08 -0800, Tom Shelton wrote:
> > His post was pure crap. *None of that was powershell. *Those were old
> > vbscripts.
>
> > Eric already posted a real powershell example... *Do you want more?
>
> I tried Powershell. Powershell is no BASH. KSH from the mid 90's is
> more powerful. BASH actually makes sense ... and is multi-platform.
>
> --
> // This is my opinion.
Liar.
HTH
--
Tom Shelton
-
Re: Windows PowerShell vs. bash examples
On Tue, 04 Nov 2008 01:46:26 -0800, Tom Shelton wrote:
> On Nov 3, 11:01*pm, jebblue wrote:
>> On Mon, 03 Nov 2008 21:31:08 -0800, Tom Shelton wrote:
>> > His post was pure crap. *None of that was powershell. *Those were old
>> > vbscripts.
>>
>> > Eric already posted a real powershell example... *Do you want more?
>>
>> I tried Powershell. Powershell is no BASH. KSH from the mid 90's is
>> more powerful. BASH actually makes sense ... and is multi-platform.
>>
>> --
>> // This is my opinion.
>
> Liar.
>
> HTH
I don't think you are the real Tom Shelton.
--
// This is my opinion.
-
Re: Windows PowerShell vs. bash examples
On Mon, 03 Nov 2008 21:31:08 -0800, Tom Shelton wrote:
> On Nov 3, 7:19*pm, Terry Porter wrote:
>> [crossposts snipped]
>>
>> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
>> > The claims that PowerShell is better than bash piqued my curiosity,
>> > so I decided to check PowerShell out.
>>
>> > I am bowed to the genius of PowerShell creators.
>>
>> Thanks Ignoramus22113!
>>
>> Most informative post indeed, and now I know what *'powershell' really
>> is ...
>>
>>
> His post was pure crap. None of that was powershell. Those were old
> vbscripts.
>
> Eric already posted a real powershell example... Do you want more?
I admit, when it comes to Eriks posts, I do expect *less*.
In the case of his 'powershell' example, it didn't look any easier than
plain old bash, certainly not the "leap" in technology Erik was raving
about.
I'm not surprised that the reality is a lot less than the claims when it
comes to Erik.
Colour me underwhelmed.
--
Linux full time, on the desktop, since August 1997
-
Re: Windows PowerShell vs. bash examples
On Tue, 04 Nov 2008 02:28:05 -0500, Erik Funkenbusch wrote:
> On Mon, 03 Nov 2008 20:26:22 -0600, Terry Porter wrote:
>
>> On Mon, 03 Nov 2008 16:45:33 -0500, Erik Funkenbusch wrote:
>>
>>> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
>>>
>>>> The claims that PowerShell is better than bash piqued my curiosity,
>>>> so I decided to check PowerShell out.
>>>>
>>>> I am bowed to the genius of PowerShell creators.
>>>>
>>>> Here's one example:
>>>>
>>>> http://www.microsoft.com/technet/scr...es/scriptshop/
>> shop0305a.mspx#EHC
>>>
>>> Uhh.. dude. Are you an idiot?
>>>
>>> That's wscript, which has been in Windows since IE4. That's not
>>> PowerShell.
>>>
>>> All your examples are wscript examples, not Powershell. What kind of
>>> a moron are you? Oh right, you're an Ignoramus.
>>
>> Please feel free to post a refutation by example to the OPs article ?
>>
>> Somehow your followup stinks of rotting Wintroll to me ...
>
> I notice you are silent on my followup post where i posted a one-line
> example similar to Ignoramus's.
>
> Why is that Terry?
Because I'm underwhelmed Erik. Powershell appears no better than the
methods Linux users have had for the last 15 years or so.
--
Linux full time, on the desktop, since August 1997
-
Re: Windows PowerShell vs. bash examples
On Wed, 05 Nov 2008 01:04:21 -0600, Terry Porter wrote:
> On Tue, 04 Nov 2008 02:28:05 -0500, Erik Funkenbusch wrote:
>
>> On Mon, 03 Nov 2008 20:26:22 -0600, Terry Porter wrote:
>>
>>> On Mon, 03 Nov 2008 16:45:33 -0500, Erik Funkenbusch wrote:
>>>
>>>> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
>>>>
>>>>> The claims that PowerShell is better than bash piqued my curiosity,
>>>>> so I decided to check PowerShell out.
>>>>>
>>>>> I am bowed to the genius of PowerShell creators.
>>>>>
>>>>> Here's one example:
>>>>>
>>>>> http://www.microsoft.com/technet/scr...es/scriptshop/
>>> shop0305a.mspx#EHC
>>>>
>>>> Uhh.. dude. Are you an idiot?
>>>>
>>>> That's wscript, which has been in Windows since IE4. That's not
>>>> PowerShell.
>>>>
>>>> All your examples are wscript examples, not Powershell. What kind of
>>>> a moron are you? Oh right, you're an Ignoramus.
>>>
>>> Please feel free to post a refutation by example to the OPs article ?
>>>
>>> Somehow your followup stinks of rotting Wintroll to me ...
>>
>> I notice you are silent on my followup post where i posted a one-line
>> example similar to Ignoramus's.
>>
>> Why is that Terry?
>
> Because I'm underwhelmed Erik. Powershell appears no better than the
> methods Linux users have had for the last 15 years or so.
For a trivial, contrived example. A one line command is a one line
command, regardless of environment. It can't really get any simpler, or
more powerful.
I was specifically responding to the comments you made by assuming
Ignoramus knew what he was talking about, then you continued to talk out of
your ass. When it turned out that virtually everything he said was wrong,
you suddenly got quiet.
We know you, Terry. If you were actually "underwhelmed", you would have
said so. You're not afraid to say anything bad about Windows whenever you
get the chance. Failing to do so can only be interpreted as "Oh ****, i
put my foot in my mouth".
-
Re: Windows PowerShell vs. bash examples
[snips]
On Wed, 05 Nov 2008 03:07:55 -0500, Erik Funkenbusch wrote:
>> Because I'm underwhelmed Erik. Powershell appears no better than the
>> methods Linux users have had for the last 15 years or so.
>
> For a trivial, contrived example. A one line command is a one line
> command, regardless of environment. It can't really get any simpler, or
> more powerful.
Err... a one-liner can be a fairly powerful critter. Try this:
tar cvzf - /wwwdata | ssh ssh user@host "dd of=/path/wwwdata.tar.gz"
-
Re: Windows PowerShell vs. bash examples
After takin' a swig o' grog, Kelsey Bjarnason belched out
this bit o' wisdom:
> [snips]
>
> On Wed, 05 Nov 2008 03:07:55 -0500, Erik Funkenbusch wrote:
>
>>> Because I'm underwhelmed Erik. Powershell appears no better than the
>>> methods Linux users have had for the last 15 years or so.
>>
>> For a trivial, contrived example. A one line command is a one line
>> command, regardless of environment. It can't really get any simpler, or
>> more powerful.
>
> Err... a one-liner can be a fairly powerful critter. Try this:
>
> tar cvzf - /wwwdata | ssh ssh user@host "dd of=/path/wwwdata.tar.gz"
I'm wondering if you can build self-installing compressed archives using
only Powershell and command-line commands.
--
[ ] DOGBERT
[ 2 ] RICHARD STALLMAN
[ 3 ] BUFFY SUMMERS
[ 1 ] MANOJ SRIVASTAVA
[ 4 ] NONE of the above
-- Debian Project Leader 1999 ballot
-
Re: Windows PowerShell vs. bash examples
On Nov 5, 12:02*am, Terry Porter wrote:
> On Mon, 03 Nov 2008 21:31:08 -0800, Tom Shelton wrote:
> > On Nov 3, 7:19*pm, Terry Porter wrote:
> >> [crossposts snipped]
>
> >> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
> >> > The claims that PowerShell is better than bash piqued my curiosity,
> >> > so I decided to check PowerShell out.
>
> >> > I am bowed to the genius of PowerShell creators.
>
> >> Thanks Ignoramus22113!
>
> >> Most informative post indeed, and now I know what *'powershell' really
> >> is ...
>
> > His post was pure crap. *None of that was powershell. *Those were old
> > vbscripts.
>
> > Eric already posted a real powershell example... *Do you want more?
>
> I admit, when it comes to Eriks posts, I do expect *less*.
>
> In the case of his 'powershell' example, it didn't look any easier than
> plain old bash, certainly not the "leap" in technology Erik was raving
> about.
>
> I'm not surprised that the reality is a lot less than the claims when it
> comes to Erik.
>
> Colour me underwhelmed.
The leap in technology is not the relative ease of use. Somethings in
powershell are harder, some are easier.
The things that makes powershell powerfull is it's object oriented
nature. If you want a fair evaluation of powershell vs bash, take a
look at this article from Linux magazine:
http://w3.linux-magazine.com/issue/7...PowerShell.pdf
And most things are easier in powershell vs the old windows scripting
host stuff (which is what ignoramus was posting as examples of
powershell). For example, disregarding the remote machine thing, the
vbscript example that ignoramus posted:
Set colOSes = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOS in colOSes
Wscript.Echo
Wscript.Echo strComputer
Wscript.Echo "OS Version: " & objOS.Version
Wscript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & _
"." & objOS.ServicePackMinorVersion
Next
translates into:
$s = [wmisearcher] 'select * from win32_operatingsystem'
$s.get() | select
@{Name="Computer";Expression={$env:computername}},@{Name = "OS
Version";Expression = {$_.Version}},@{Name = "Service
Pack";Expression={[string]::Format("{0}.{1}",
$_.ServicePackMajorVersion, $_.ServicePackMinorVersion)}} | fl
The output is:
Computer : ARAGORN
OS Version : 5.1.2600
Service Pack : 3.0
Now is that easier then bash? Maybe, maybe not if you understand what
that script is doing - the above expression could be a lot simpler,
but I was producing format comparable to the vbscript example.
Understand that what get's passed between the $s.get() and the select
via the | is not just a string, it is a real object. And that is what
differentiates powershell from bash (not the only thing, but one of
the major ones).
--
Tom Shelton
-
Re: Windows PowerShell vs. bash examples
On Nov 5, 5:57*am, Chris Ahlstrom wrote:
> After takin' a swig o' grog, Kelsey Bjarnason belched out
> * this bit o' wisdom:
>
> > [snips]
>
> > On Wed, 05 Nov 2008 03:07:55 -0500, Erik Funkenbusch wrote:
>
> >>> Because I'm underwhelmed Erik. Powershell appears no better than the
> >>> methods Linux users have had for the last 15 years or so.
>
> >> For a trivial, contrived example. *A one line command is a one line
> >> command, regardless of environment. *It can't really get any simpler, or
> >> more powerful.
>
> > Err... a one-liner can be a fairly powerful critter. *Try this:
>
> > tar cvzf - /wwwdata | ssh ssh user@host "dd of=/path/wwwdata.tar.gz"
>
> I'm wondering if you can build self-installing compressed archives using
> only Powershell and command-line commands.
>
Out of the box, probably not. But, it would be fairly trivial to
write a function or commandlet that used sharpziplib to compress/
decompress zip archives.
--
Tom Shelton
-
Re: Windows PowerShell vs. bash examples
After takin' a swig o' grog, Tom Shelton belched out
this bit o' wisdom:
> And most things are easier in powershell vs the old windows scripting
> host stuff (which is what ignoramus was posting as examples of
> powershell). For example, disregarding the remote machine thing, the
> vbscript example that ignoramus posted:
>
> Set colOSes = objWMIService.ExecQuery _
> ("SELECT * FROM Win32_OperatingSystem")
> For Each objOS in colOSes
> Wscript.Echo
> Wscript.Echo strComputer
> Wscript.Echo "OS Version: " & objOS.Version
> Wscript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & _
> "." & objOS.ServicePackMinorVersion
> Next
>
> translates into:
>
> $s = [wmisearcher] 'select * from win32_operatingsystem'
> $s.get() | select
> @{Name="Computer";Expression={$env:computername}},@{Name = "OS
> Version";Expression = {$_.Version}},@{Name = "Service
> Pack";Expression={[string]::Format("{0}.{1}",
> $_.ServicePackMajorVersion, $_.ServicePackMinorVersion)}} | fl
>
> The output is:
>
> Computer : ARAGORN
> OS Version : 5.1.2600
> Service Pack : 3.0
>
> Now is that easier then bash? Maybe, maybe not if you understand what
> that script is doing - the above expression could be a lot simpler,
> but I was producing format comparable to the vbscript example.
> Understand that what get's passed between the $s.get() and the select
> via the | is not just a string, it is a real object. And that is what
> differentiates powershell from bash (not the only thing, but one of
> the major ones).
Python:
http://www.thescriptlibrary.com/defa...ory1=Operating System&Category2=Version Information&Title=List Operating System Properties
import win32com.client
strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_OperatingSystem")
for objItem in colItems:
print "Service Pack Major Version: ", objItem.ServicePackMajorVersion
print "Service Pack Minor Version: ", objItem.ServicePackMinorVersion
--
"If I ever get around to writing that language depompisifier, it will change
almost all occurrences of the word "paradigm" into "example" or "model."
-- Herbie Blashtfalt
-
Re: Windows PowerShell vs. bash examples
After takin' a swig o' grog, Tom Shelton belched out
this bit o' wisdom:
> On Nov 5, 5:57*am, Chris Ahlstrom wrote:
>
>> I'm wondering if you can build self-installing compressed archives using
>> only Powershell and command-line commands.
>
> Out of the box, probably not. But, it would be fairly trivial to
> write a function or commandlet that used sharpziplib to compress/
> decompress zip archives.
I don't mind if the script uses an external app like tar. I was wondering
if you can create a package structured like this:
#!/bin/sh
export TMPDIR=`mktemp -d /tmp/LinuxBuildInstaller.XXXXXX`
ARCHIVE=`awk '/^_____ARCHIVE__FOLLOWS_____/ { print NR + 1 ; exit 0 ; }' $0`
tail -n+$ARCHIVE $0 | tar xzv -C $TMPDIR
CURRENT_DIR=`pwd`
cd $TMPDIR
../LinuxBuildRawInstaller
_____ARCHIVE__FOLLOWS_____
^_<8b>^H^@ÝÄ*H^@^Cì\ t .... (binary data for the tar file)
--
A-Z affectionately,
1 to 10 alphabetically,
from here to eternity without in betweens,
still looking for a custom fit in an off-the-rack world,
sales talk from sales assistants
when all i want to do is lower your resistance,
no rhythm in cymbals no tempo in drums,
love's on arrival,
she comes when she comes,
right on the target but wide of the mark...
-
Re: Windows PowerShell vs. bash examples
On Nov 5, 9:55*am, Chris Ahlstrom wrote:
> After takin' a swig o' grog, Tom Shelton belched out
> * this bit o' wisdom:
>
>
>
> > And most things are easier in powershell vs the old windows scripting
> > host stuff (which is what ignoramus was posting as examples of
> > powershell). *For example, disregarding the remote machine thing, the
> > vbscript example that ignoramus posted:
>
> > Set colOSes = objWMIService.ExecQuery _
> > *("SELECT * FROM Win32_OperatingSystem")
> > For Each objOS in colOSes
> > * Wscript.Echo
> > * Wscript.Echo strComputer
> > * Wscript.Echo "OS Version: " & objOS.Version
> > * Wscript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & _
> > * *"." & objOS.ServicePackMinorVersion
> > Next
>
> > translates into:
>
> > $s = [wmisearcher] 'select * from win32_operatingsystem'
> > $s.get() | select
> > @{Name="Computer";Expression={$env:computername}},@{Name = "OS
> > Version";Expression = {$_.Version}},@{Name = "Service
> > Pack";Expression={[string]::Format("{0}.{1}",
> > $_.ServicePackMajorVersion, $_.ServicePackMinorVersion)}} | fl
>
> > The output is:
>
> > Computer * * : ARAGORN
> > OS Version * : 5.1.2600
> > Service Pack : 3.0
>
> > Now is that easier then bash? *Maybe, maybe not if you understand what
> > that script is doing - the above expression could be a lot simpler,
> > but I was producing format comparable to the vbscript example.
> > Understand that what get's passed between the $s.get() and the select
> > via the | is not just a string, it is a real object. *And that is what
> > differentiates powershell from bash (not the only thing, but one of
> > the major ones).
>
> Python:
>
> * *http://www.thescriptlibrary.com/defa...egory2=Version Information&Title=List Operating System Properties
>
> * *import win32com.client
> * *strComputer = "."
> * *objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
> * *objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
> * *colItems = objSWbemServices.ExecQuery("Select * from Win32_OperatingSystem")
> * *for objItem in colItems:
> * * * print "Service Pack Major Version: ", objItem.ServicePackMajorVersion
> * * * print "Service Pack Minor Version: ", objItem.ServicePackMinorVersion
>
> --
> "If I ever get around to writing that language depompisifier, it will change
> almost all occurrences of the word "paradigm" into "example" or "model."
> * * * * * * * * -- Herbie Blashtfalt
While, thats a nice python example - that isn't the shell. Nor is it
much different then the vbscript example. My shell script is two lines
- and really could be one 
--
Tom Shelton
-
Re: Windows PowerShell vs. bash examples
On Nov 5, 10:01*am, Chris Ahlstrom wrote:
> After takin' a swig o' grog, Tom Shelton belched out
> * this bit o' wisdom:
>
> > On Nov 5, 5:57*am, Chris Ahlstrom wrote:
>
> >> I'm wondering if you can build self-installing compressed archives using
> >> only Powershell and command-line commands.
>
> > Out of the box, probably not. *But, it would be fairly trivial to
> > write a function or commandlet that used sharpziplib to compress/
> > decompress zip archives.
>
> I don't mind if the script uses an external app like tar. *I was wondering
> if you can create a package structured like this:
>
> #!/bin/sh
> export TMPDIR=`mktemp -d /tmp/LinuxBuildInstaller.XXXXXX`
> ARCHIVE=`awk '/^_____ARCHIVE__FOLLOWS_____/ { print NR + 1 ; exit 0 ; }' $0`
> tail -n+$ARCHIVE $0 | tar xzv -C $TMPDIR
> CURRENT_DIR=`pwd`
> cd $TMPDIR
> ./LinuxBuildRawInstaller
> _____ARCHIVE__FOLLOWS_____
> ^_<8b>^H^@ Ä*H^@^Cì\ t *.... (binary data for the tarfile)
>
Assuming you have an archiving tool, I don't see why not.
--
Tom Shelton
-
Re: Windows PowerShell vs. bash examples
On 2008-11-05, Tom Shelton wrote:
> On Nov 5, 12:02*am, Terry Porter wrote:
>> On Mon, 03 Nov 2008 21:31:08 -0800, Tom Shelton wrote:
>> > On Nov 3, 7:19*pm, Terry Porter wrote:
>> >> [crossposts snipped]
>>
>> >> On Sun, 02 Nov 2008 22:37:57 -0600, Ignoramus22113 wrote:
[deletia]
>> In the case of his 'powershell' example, it didn't look any easier than
>> plain old bash, certainly not the "leap" in technology Erik was raving
>> about.
>>
>> I'm not surprised that the reality is a lot less than the claims when it
>> comes to Erik.
>>
>> Colour me underwhelmed.
>
> The leap in technology is not the relative ease of use. Somethings in
> powershell are harder, some are easier.
>
> The things that makes powershell powerfull is it's object oriented
> nature. If you want a fair evaluation of powershell vs bash, take a
> look at this article from Linux magazine:
....which seems to be a great thing for software engineering and a
pisspoor thing for scripting.
Take a simple problem and make it needlessly complex.
Every powershell example I've ever seen has fit this description.
[deletia]
The whole "object oriented" bit just seems to be a buzzword bingo.
--
NO! There are no CODICILES of Fight Club! |||
/ | \
That way leads to lawyers and business megacorps and credit cards!
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
-
Re: Windows PowerShell vs. bash examples
After takin' a swig o' grog, Tom Shelton belched out
this bit o' wisdom:
> On Nov 5, 9:55*am, Chris Ahlstrom wrote:
>> After takin' a swig o' grog, Tom Shelton belched out
>>
>> > $s = [wmisearcher] 'select * from win32_operatingsystem'
>> > $s.get() | select
>> > @{Name="Computer";Expression={$env:computername}},@{Name = "OS
>> > Version";Expression = {$_.Version}},@{Name = "Service
>> > Pack";Expression={[string]::Format("{0}.{1}",
>> > $_.ServicePackMajorVersion, $_.ServicePackMinorVersion)}} | fl
>>
>> Python:
>>
>> http://www.thescriptlibrary.com/defa...egory2=Version Information&Title=List Operating System Properties
>>
>> import win32com.client
>> strComputer = "."
>> objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
>> objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
>> colItems = objSWbemServices.ExecQuery("Select * from Win32_OperatingSystem")
>> for objItem in colItems:
>> print "Service Pack Major Version: ", objItem.ServicePackMajorVersion
>> print "Service Pack Minor Version: ", objItem.ServicePackMinorVersion
>
> While, thats a nice python example - that isn't the shell. Nor is it
> much different then the vbscript example. My shell script is two lines
> - and really could be one 
Whatever, dude. You can type that example into the Python *shell*, and run
it from there.
And I count six lines in your example, not two.
Here's my bash one-liner:
$ cat /etc/motd
(Doesn't tell you the version of Debian, though. I'll let somebody else
supply the second line.)
--
Friction is a drag.