Windows PowerShell vs. bash examples - Linux

This is a discussion on Windows PowerShell vs. bash examples - Linux ; 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...0305a.mspx#EHC Let's call our input text file hosts.txt and put ...

+ Reply to Thread
Page 1 of 11 1 2 3 ... LastLast
Results 1 to 20 of 217

Thread: Windows PowerShell vs. bash examples

  1. Windows PowerShell vs. bash examples

    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...0305a.mspx#EHC

    Let's call our input text file hosts.txt and put one computer name per
    line. These computers need to be accessible on the network and you
    must have Administrator privileges on them (as is usually true when
    you run a script against a remote machine [*** Cool gem
    here!***]). Our file should look something like this:

    client1
    client2
    client3
    client4

    We extract the computer names from the file with the trusty
    FileSystemObject, part of Script Runtime (included with Windows Script
    Host). Here's what the code looks like (we hope this will be
    sleep-inducingly familiar to many of you).

    Const FOR_READING = 1
    strFilename = "hosts.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextStream = objFSO.OpenTextFile(strFilename, FOR_READING)
    Do Until objTextStream.AtEndOfStream
    strComputer = objTextStream.ReadLine
    Wscript.Echo "Use WMI to get OS and SP versions from " & strComputer
    Loop

    What we get back from the OpenTextFile method of FileSystemObject is
    actually an object representing a text stream. This object has handy
    properties such as AtEndOfStream and methods such as ReadLine that we
    use here to pull out one line at a time.

    Very "sleep inducingly" indeed.

    ##############################

    And here's how you do it with bash:

    awk '{print "Use WMI to get OS and SP versions from " $1}' < hosts.txt

    You see now how PowerShell is so superior? So much easier to read?

    Let's go to the next one:

    ################################################## ####################
    http://www.microsoft.com/technet/scr...0305a.mspx#EUC

    Retrieving operating system version and Service Pack

    To find out the operating system and service pack of computers, we use
    three properties of theWMI class Win32_OperatingSystem: Version,
    ServicePackMajorVersion and ServicePackMinorVersion.

    To get these, we connect to WMI on the computer in question and query
    for instances of the Win32_OperatingSystem class. (This query always
    returns only one instance, the operating system that is currently
    running.) Then we display these three properties, concatenating
    together ServicePackMajorVersion and ServicePackMinorVersion with a
    period in between.

    'Get strComputer from each line of text file.
    Set objWMIService = GetObject("winmgmts://" & strComputer)
    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

    If we ran this, we would get output something like the following.

    client1
    OS Version: 5.1.2600
    Service Pack: 2.0

    If we wanted to display the name of the operating system rather than
    the version number, we could use the Caption property, which might be
    a bit more legible, rather than Version. In any case, in this script,
    we're only interested in Windows XP.

    We could put the two components we've created together and get the OS
    version and service pack on those four machines. The output would look
    like this:

    C:\scripts>xpsplist-wmi.vbs

    client1
    OS Version: 5.1.2600
    Service Pack: 1.0

    client2
    OS Version: 5.1.2600
    Service Pack: 2.0

    client3
    OS Version: 5.1.2600
    Service Pack: 2.0

    client4
    OS Version: 5.1.2600
    Service Pack:

    This is straightforward WMI, and many of you are no doubt yawning and
    craving that second cup of coffee at this point. But that's part of
    the beauty of scripting technologies: once you learn them, they're
    routine and easy to use. In this column, we're going to try to put the
    pieces of them together in slightly more complex and practical ways,
    but most of the building blocks are the same old stuff. Remember
    Dr. Scripto's timeless wisdom: "Be lazy (IT managers should read
    'productive'). Don't reinvent the wheel."

    ##############################

    Now onto bash and Linux examples:

    (using remote query)

    for server in $(echo "select hostname from servers" | mysql -uusername -ppassword); do
    ssh -l userid $server lsb_release -a
    done

    or (SQL only)

    echo "select os, spackminor, spackmajor from Win32_OperatingSystem" \
    | mysql -uusername -ppassword \
    | awk '{print "\nOS Version: " $1 "\nService Pack: " $3 "." $2;}'


    One more gem:

    ################################################## ####################
    http://www.microsoft.com/technet/scr...0305a.mspx#EMD

    Const FOR_APPENDING = 8
    strOutputFile = "xpsp.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(strOutputFile) Then
    Set objTextStream = objFSO.OpenTextFile(strOutputFile, FOR_APPENDING)
    Else
    Set objTextStream = objFSO.CreateTextFile(strOutputFile)
    End If

    objTextStream.WriteLine "Inventory of Windows XP Service Packs"
    objTextStream.WriteLine "Taken " & Now
    objTextStream.WriteLine vbCrLf & "Computers Running Windows XP"
    objTextStream.WriteLine "============================"
    objTextStream.WriteLine "Total number: " & (intSP2 + intSP1 + intSP0)

    objTextStream.WriteLine vbCrLf & "Service Pack 2"
    objTextStream.WriteLine "--------------"
    objTextStream.WriteLine strSP2
    objTextStream.WriteLine "Total number: " & intSP2

    objTextStream.WriteLine vbCrLf & "Service Pack 1"
    objTextStream.WriteLine "--------------"
    objTextStream.WriteLine strSP1
    objTextStream.WriteLine "Total number: " & intSP1

    objTextStream.WriteLine vbCrLf & "No Service Pack"
    objTextStream.WriteLine "---------------"
    objTextStream.WriteLine strSP0
    objTextStream.WriteLine "Total number: " & intSP0

    objTextStream.WriteLine vbCrLf & "Computers Not Running Windows XP"
    objTextStream.WriteLine "================================"
    objTextStream.WriteLine "Total number: " & intNotXP

    objTextStream.WriteLine vbCrLf & "Could Not Connect To Computer"
    objTextStream.WriteLine "============================="
    objTextStream.WriteLine "Total number: " & intErr
    objTextStream.WriteLine

    objTextStream.Close

    ##############################

    This perfect example would look terrible in bash, of course

    (
    cat << _EOB_
    Inventory of Windows XP Service Packs
    Taken `date`
    Computers Running Windows XP
    ============================
    Total number: $(echo $intSP2+$intSP1+$intSP0|bc -l)

    Service Pack 2
    --------------
    $strSP2
    Total number: $intSP

    Service Pack 1
    --------------
    $strSP1
    Total number: $intSP1

    No Service Pack
    ---------------
    $strSP0
    Total number: $intSP0

    Computers Not Running Windows XP
    ================================
    Total number: $intNotX

    Could Not Connect To Computer
    =============================
    Total number: $intEr
    _EOB_
    ) >> xpsp.txt

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Jokes aside, it is obvious to me that PowerShell is nowhere near
    actually being able to use it effectively for daily stuff.

  2. Re: Windows PowerShell vs. bash examples

    Ignoramus22113 wrote:
    > The claims that PowerShell is better than bash piqued my curiosity, so
    > I decided to check PowerShell out.
    > (...)
    > Jokes aside, it is obvious to me that PowerShell is nowhere near
    > actually being able to use it effectively for daily stuff.


    I was a bit perplexed when I first saw PowerShell examples. It looked so
    verbose, so unlike a scripting language. If I had PowerShell back in
    Windows 2000 I might have continued to administer Windows system but that
    ship as sailed (or should I say has sunk or was scrapped).

    Now I have enough GNU/Linux systems to keep me busy scripting for.

    Regards.

  3. Re: Windows PowerShell vs. bash examples

    Cork Soaker skrev:
    > Could you say that again?


    Not him but I


    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...0305a.mspx#EHC

    Let's call our input text file hosts.txt and put one computer name per
    line. These computers need to be accessible on the network and you
    must have Administrator privileges on them (as is usually true when
    you run a script against a remote machine [*** Cool gem
    here!***]). Our file should look something like this:

    client1
    client2
    client3
    client4

    We extract the computer names from the file with the trusty
    FileSystemObject, part of Script Runtime (included with Windows Script
    Host). Here's what the code looks like (we hope this will be
    sleep-inducingly familiar to many of you).

    Const FOR_READING = 1
    strFilename = "hosts.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextStream = objFSO.OpenTextFile(strFilename, FOR_READING)
    Do Until objTextStream.AtEndOfStream
    strComputer = objTextStream.ReadLine
    Wscript.Echo "Use WMI to get OS and SP versions from " & strComputer
    Loop

    What we get back from the OpenTextFile method of FileSystemObject is
    actually an object representing a text stream. This object has handy
    properties such as AtEndOfStream and methods such as ReadLine that we
    use here to pull out one line at a time.

    Very "sleep inducingly" indeed.

    ##############################

    And here's how you do it with bash:

    awk '{print "Use WMI to get OS and SP versions from " $1}' < hosts.txt

    You see now how PowerShell is so superior? So much easier to read?

    Let's go to the next one:

    ################################################## ####################
    http://www.microsoft.com/technet/scr...0305a.mspx#EUC

    Retrieving operating system version and Service Pack

    To find out the operating system and service pack of computers, we use
    three properties of theWMI class Win32_OperatingSystem: Version,
    ServicePackMajorVersion and ServicePackMinorVersion.

    To get these, we connect to WMI on the computer in question and query
    for instances of the Win32_OperatingSystem class. (This query always
    returns only one instance, the operating system that is currently
    running.) Then we display these three properties, concatenating
    together ServicePackMajorVersion and ServicePackMinorVersion with a
    period in between.

    'Get strComputer from each line of text file.
    Set objWMIService = GetObject("winmgmts://" & strComputer)
    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

    If we ran this, we would get output something like the following.

    client1
    OS Version: 5.1.2600
    Service Pack: 2.0

    If we wanted to display the name of the operating system rather than
    the version number, we could use the Caption property, which might be
    a bit more legible, rather than Version. In any case, in this script,
    we're only interested in Windows XP.

    We could put the two components we've created together and get the OS
    version and service pack on those four machines. The output would look
    like this:

    C:\scripts>xpsplist-wmi.vbs

    client1
    OS Version: 5.1.2600
    Service Pack: 1.0

    client2
    OS Version: 5.1.2600
    Service Pack: 2.0

    client3
    OS Version: 5.1.2600
    Service Pack: 2.0

    client4
    OS Version: 5.1.2600
    Service Pack:

    This is straightforward WMI, and many of you are no doubt yawning and
    craving that second cup of coffee at this point. But that's part of
    the beauty of scripting technologies: once you learn them, they're
    routine and easy to use. In this column, we're going to try to put the
    pieces of them together in slightly more complex and practical ways,
    but most of the building blocks are the same old stuff. Remember
    Dr. Scripto's timeless wisdom: "Be lazy (IT managers should read
    'productive'). Don't reinvent the wheel."

    ##############################

    Now onto bash and Linux examples:

    (using remote query)

    for server in $(echo "select hostname from servers" | mysql -uusername
    -ppassword); do
    ssh -l userid $server lsb_release -a
    done

    or (SQL only)

    echo "select os, spackminor, spackmajor from Win32_OperatingSystem" \
    | mysql -uusername -ppassword \
    | awk '{print "\nOS Version: " $1 "\nService Pack: " $3 "." $2;}'


    One more gem:

    ################################################## ####################
    http://www.microsoft.com/technet/scr...0305a.mspx#EMD

    Const FOR_APPENDING = 8
    strOutputFile = "xpsp.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(strOutputFile) Then
    Set objTextStream = objFSO.OpenTextFile(strOutputFile, FOR_APPENDING)
    Else
    Set objTextStream = objFSO.CreateTextFile(strOutputFile)
    End If

    objTextStream.WriteLine "Inventory of Windows XP Service Packs"
    objTextStream.WriteLine "Taken " & Now
    objTextStream.WriteLine vbCrLf & "Computers Running Windows XP"
    objTextStream.WriteLine "============================"
    objTextStream.WriteLine "Total number: " & (intSP2 + intSP1 + intSP0)

    objTextStream.WriteLine vbCrLf & "Service Pack 2"
    objTextStream.WriteLine "--------------"
    objTextStream.WriteLine strSP2
    objTextStream.WriteLine "Total number: " & intSP2

    objTextStream.WriteLine vbCrLf & "Service Pack 1"
    objTextStream.WriteLine "--------------"
    objTextStream.WriteLine strSP1
    objTextStream.WriteLine "Total number: " & intSP1

    objTextStream.WriteLine vbCrLf & "No Service Pack"
    objTextStream.WriteLine "---------------"
    objTextStream.WriteLine strSP0
    objTextStream.WriteLine "Total number: " & intSP0

    objTextStream.WriteLine vbCrLf & "Computers Not Running Windows XP"
    objTextStream.WriteLine "================================"
    objTextStream.WriteLine "Total number: " & intNotXP

    objTextStream.WriteLine vbCrLf & "Could Not Connect To Computer"
    objTextStream.WriteLine "============================="
    objTextStream.WriteLine "Total number: " & intErr
    objTextStream.WriteLine

    objTextStream.Close

    ##############################

    This perfect example would look terrible in bash, of course

    (
    cat << _EOB_
    Inventory of Windows XP Service Packs
    Taken `date`
    Computers Running Windows XP
    ============================
    Total number: $(echo $intSP2+$intSP1+$intSP0|bc -l)

    Service Pack 2
    --------------
    $strSP2
    Total number: $intSP

    Service Pack 1
    --------------
    $strSP1
    Total number: $intSP1

    No Service Pack
    ---------------
    $strSP0
    Total number: $intSP0

    Computers Not Running Windows XP
    ================================
    Total number: $intNotX

    Could Not Connect To Computer
    =============================
    Total number: $intEr
    _EOB_
    ) >> xpsp.txt

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Jokes aside, it is obvious to me that PowerShell is nowhere near
    actually being able to use it effectively for daily stuff.

  4. Re: Windows PowerShell vs. bash examples

    After takin' a swig o' grog, Sven Svenson belched out
    this bit o' wisdom:

    > I am bowed to the genius of PowerShell creators.
    >
    > http://www.microsoft.com/technet/scr...0305a.mspx#EUC
    >
    > 'Get strComputer from each line of text file.
    > Set objWMIService = GetObject("winmgmts://" & strComputer)
    > 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


    How very Microsoft-specific.

    Why not use this (proprietary) tool:

    http://www.mkssoftware.com/docs/man1/uname.1.asp

    (uname for Windows)

    Oh, no service pack info.

    --
    This fortune is false.

  5. Re: Windows PowerShell vs. bash examples

    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

  6. Re: Windows PowerShell vs. bash examples

    On 2008-11-03, 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.


    Try to cheat like this in PowerShell.

    --
    Due to extreme spam originating from Google Groups, and their inattention
    to spammers, I and many others block all articles originating
    from Google Groups. If you want your postings to be seen by
    more readers you will need to find a different means of
    posting on Usenet.
    http://improve-usenet.org/

  7. Re: Windows PowerShell vs. bash examples

    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


    In comp.os.linux.misc jellybean stonerfish wrote:
    > You cheated. You are supposed to do it in bash, not use bash to call
    > awk.


    You mean like this (one liner)? ;-)

    while read H; do echo "Use WMI to get OS and SP versions from $H"; \
    done
    Chris

  8. Re: Windows PowerShell vs. bash examples

    On 2008-11-03, Chris Davies 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

    >
    > In comp.os.linux.misc jellybean stonerfish wrote:
    >> You cheated. You are supposed to do it in bash, not use bash to call
    >> awk.

    >
    > You mean like this (one liner)? ;-)
    >
    > while read H; do echo "Use WMI to get OS and SP versions from $H"; \
    > done >
    > Chris


    I do not see how one can have any "bash vs. PowerShell" contest
    without using the rest of GNU utilities, which usually come with
    bash.

    The whole point of bash is to NOT be a bloated pig like powershell,
    and instead use I/O intelligently to use numerous helper processes
    like awk, date, ls, etc, and to not crash if those helpers develop a
    fatal error.

    --
    Due to extreme spam originating from Google Groups, and their inattention
    to spammers, I and many others block all articles originating
    from Google Groups. If you want your postings to be seen by
    more readers you will need to find a different means of
    posting on Usenet.
    http://improve-usenet.org/

  9. Re: Windows PowerShell vs. bash examples

    On 2008-11-03, Ignoramus7766 wrote:
    > On 2008-11-03, Chris Davies 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

    >>
    >> In comp.os.linux.misc jellybean stonerfish wrote:
    >>> You cheated. You are supposed to do it in bash, not use bash to call
    >>> awk.

    >>
    >> You mean like this (one liner)? ;-)
    >>
    >> while read H; do echo "Use WMI to get OS and SP versions from $H"; \
    >> done >>
    >> Chris

    >
    > I do not see how one can have any "bash vs. PowerShell" contest
    > without using the rest of GNU utilities, which usually come with
    > bash.


    Agreed. Bash vs. PowerShell is a pointless comparison. Nobody
    installs Bash on a Unix system without any other command-line
    utilities. Bash is is only one component of a Unix
    command-line environment. The proper comparison is PowerShell
    vs. Unix-command-line-tools.

    > The whole point of bash is to NOT be a bloated pig like
    > powershell, and instead use I/O intelligently to use numerous
    > helper processes like awk, date, ls, etc, and to not crash if
    > those helpers develop a fatal error.


    Yup.

    --
    Grant Edwards grante Yow! Why is it that when
    at you DIE, you can't take
    visi.com your HOME ENTERTAINMENT
    CENTER with you??

  10. Re: Windows PowerShell vs. bash examples

    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...0305a.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.

  11. Re: Windows PowerShell vs. bash examples

    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


    And here's one of any number of ways you can do it in PowerShell:

    gc hosts.txt | Foreach-object {echo "Use WMI to get OS and SP versions from $_"}

  12. Re: Windows PowerShell vs. bash examples

    On Nov 3, 12:18*pm, Ignoramus7766
    wrote:
    > On 2008-11-03, Chris Davies 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

    >
    > > In comp.os.linux.misc jellybean stonerfish wrote:
    > >> You cheated. *You are supposed to do it in bash, not use bash to call
    > >> awk.

    >
    > > You mean like this (one liner)? *;-)

    >
    > > * * while read H; do echo "Use WMI to get OS and SP versions from $H"; \
    > > * * done
    >
    > > Chris

    >
    > I do not see how one can have any "bash vs. PowerShell" contest
    > without using the rest of GNU utilities, which usually come with
    > bash.
    >
    > The whole point of bash is to NOT be a bloated pig like powershell,
    > and instead use I/O intelligently to use numerous helper processes
    > like awk, date, ls, etc, and to not crash if those helpers develop a
    > fatal error.
    >


    Except that none of your examples were powershell at all. You are
    completely clueless.

    HTH

    --
    Tom Shelton

  13. Re: Windows PowerShell vs. bash examples

    LusoTec wrote:

    > Ignoramus22113 wrote:
    >> The claims that PowerShell is better than bash piqued my curiosity, so
    >> I decided to check PowerShell out.
    >> (...)
    >> Jokes aside, it is obvious to me that PowerShell is nowhere near
    >> actually being able to use it effectively for daily stuff.

    >
    > I was a bit perplexed when I first saw PowerShell examples. It looked so
    > verbose, so unlike a scripting language. If I had PowerShell back in
    > Windows 2000 I might have continued to administer Windows system but that
    > ship as sailed (or should I say has sunk or was scrapped).
    >
    > Now I have enough GNU/Linux systems to keep me busy scripting for.
    >
    > Regards.


    They can't help themselves at Microsoft. Everything has to look like Visual Basic.

    Ian

  14. Re: Windows PowerShell vs. bash examples


    "jellybean stonerfish" wrote in message
    news:490f1b62$0$31742$bd467cd0@news.dslextreme.com ...
    > 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


    It wasn't cheating. Awk is part of the things bash can call. Using any one
    of a dozen different ways is up to the author. But if you must:

    while read line; do echo "Use WMI to get OS and SP versions from ${line}";
    done < hosts.txt

    One liner. Why make it more (Microsoft) complex and slower than it needs to
    be.

    Next issue, UNIX/Linux people have more fun on dates too. MS-Windows for
    boys, X-Windows for men.

    Go back toy your MS-Windows pond.
    --------
    {man;look;for;cat;nice;gawk;find;whois;init;sed;ta lk;date;grep;touch;finger;
    flex;unzip;head;tail;mount;workbone;fsck;yes;gasp; fsck;more;yes;yes;
    eject;umount;makeclean;zip;sort;done;cu;split;exit :xargs!!}











  15. Re: Windows PowerShell vs. bash examples

    [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 ...

    .... just the same old Microsoft crap, nothing new here folks, move on ..

    Thanks for taking the Funkenbusch Wintroll up on this topic, you have
    shown his comments to be wildly inaccurate as usual.

    BTW, only the wisest of the wise would ever call themselves "Ignoramus",
    so we are on to you mate ;-)

    Cheers
    Terry


    --
    Linux full time, on the desktop, since August 1997

  16. Re: Windows PowerShell vs. bash examples

    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 ...


    --
    Linux full time, on the desktop, since August 1997

  17. Re: Windows PowerShell vs. bash examples

    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

    --
    Paul Hovnanian mailto:Paul@Hovnanian.com
    ------------------------------------------------------------------
    Child prodigy procrastinator.

  18. Re: Windows PowerShell vs. bash examples

    In news:4OSdnb4d-ce4HZPUnZ2dnUVZ_u6dnZ2d@giganews.com,
    Ignoramus22113 typed:

    > I am bowed to the genius of PowerShell creators.


    While you're down there ...



  19. Re: Windows PowerShell vs. bash examples

    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

    --
    Due to extreme spam originating from Google Groups, and their inattention
    to spammers, I and many others block all articles originating
    from Google Groups. If you want your postings to be seen by
    more readers you will need to find a different means of
    posting on Usenet.
    http://improve-usenet.org/

  20. Re: Windows PowerShell vs. bash examples


    "Ignoramus7766" wrote in message
    news:zq6dnV0y-KEPXpLUnZ2dnUVZ_s3inZ2d@giganews.com...
    > 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


    That sed line, real fast and super simple.



+ Reply to Thread
Page 1 of 11 1 2 3 ... LastLast