WSF script that pulls server names from a file

Discussion in 'Scripting' started by Ralph, Aug 7, 2003.

  1. Ralph

    Ralph Guest

    I have a WSF script, but I need to run it against a list
    of servers from a txt file. How do I do this?

    Thanks
     
    Ralph, Aug 7, 2003
    #1
    1. Advertisements

  2. On the commandline, use a FOR loop to go through the list in a txt file,
    then invoke the WSF script with parameters.

    FOR /? to get help.

    FOR /F %I in ( File.txt ) DO ECHO Command %I

    If File.txt contains
    Server1
    Server2
    Server3

    Output is
    Command Server1
    Command Server2
    Command Server3


    Remove ECHO, and you execute the command.


    If your file has more than just server name, you'll need to parse it.
    Hopefully, it is in a structured, delimited manner, which allows you to use
    FOR.

    for /F "tokens=1-3 delims= " %I in (test.txt) do @ECHO Command %I - %J - %K

    If File.txt contains
    1. Server1 FOO
    2. Server2 BAR
    3. Server3 BAZ

    Output is
    Command 1. - Server1 - FOO
    Command 2. - Server2 - BAR
    Command 3. - Server3 - BAZ

    --
    //David
    This posting is provided "AS IS" with no warranties, and confers no rights.
    //
    I have a WSF script, but I need to run it against a list
    of servers from a txt file. How do I do this?

    Thanks
     
    David Wang [Msft], Aug 9, 2003
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.