1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Piping Commands in CMD for XP

Discussion in 'Software' started by Fergal1982, Nov 16, 2005.

  1. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    Can anyone tell me how to pipe the output of a command into a specific variable of a piped command?

    For instance, i want to take the output of:

    Code:
    dsquery user -name fergal.reilly
    into:

    Code:
    dsget user xxx -memberof
    at the xxx location.

    Thanks
    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  2. Neall

    Neall Byte Poster

    214
    6
    0
    Google came with;

    http://www.computerperformance.co.uk/Logon/DSGet.htm

    http://64.233.183.104/search?q=cach...om+dsquery+into+dsget+&hl=en&client=firefox-a
     
    WIP: A+
  3. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I didn't follow Neall's links but if you run "dsget /?" from a command prompt the help screen will actually show you how you pipe the output of one dsquery into dsget. All you do is use the | symbol between the two commands. That is the symbol you get when you hit shift + \.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  4. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    i know how to pipe, i just cant get it to pipe the output to a specific section of the input for some reason.

    However, in the context of the above example, i think the -dn switch does it. but id like to know how to do it generically, the above are current examples only, might want to do it with other commands.

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  5. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    I don't understand what you are trying to do. When you pipe the output of dsquery into dsget you're going to get a list. What are you trying to use the xxx for? Is that a dsget parameter? What? I don't see anything in the dsget syntax that shows another paramter like that in the way you're trying to use it, but then maybe, as I said above, I'm confused as to exactly what you're trying to do.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  6. Fergal1982

    Fergal1982 Petabyte Poster

    4,196
    171
    211
    i was using those commands as an example of what i meant. xxx is the location in the command where i want to input the output from the previous command.

    ill give another example, say i want to list all text files called 'test' on my C: drive, and have them all open in notepad, id use something like this (id expect):

    Code:
    dir test.txt /s | notepad xxx
    what i dont know, is what to put where xxx is in order to make it open all those results. If i just put 'notepad', all that would happen would be that a blank text file would open in notepad (ive tried it).

    Fergal
     
    Certifications: ITIL Foundation; MCTS: Visual Studio Team Foundation Server 2010, Administration
    WIP: None at present
  7. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Well, that's kind of an odd use of the dir command. Here's how I would use it.

    "dir C:\Program Files > c:\test.txt" If I did this in a script I would then call notepad and tell it to open c:\test.txt: notepad c:\test.txt. I don't think you can pipe the output directly into notepad because the file you're creating will be in use at the time you call notepad.
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1

Share This Page

Loading...