Win32 Shell Script question

  • 12 years ago

    Win2003 

    I have a script that looks like this ...

    FOR /F %%a IN (List-of-Daily-Full-Groups.txt) DO mminfo -avot -q "group=%%a" -r "client,pool,volume,name,group,savetime(22),ssid,ssflags,clflags" >>Volumes.txt

    )

    Now, the file "List-of-Daily-Full-Groups.txt" looks like this ...

    ADMNLTS003

    Daily ADMNDEV002 SQL disk-only

    (I can't seem to figure out how to turn off HTML .. the above 2 lines are consecutive, no line break, in the input file for the loop)

    The loop works fine for the value ADMNLTS003, but dies on the 2nd entry. Apparently, it's stopping at the first space, so the loop is executing as:

    mminfo -avot -q "group=Daily" -r "client,pool,volume,name,group,savetime(22),ssid,ssflags,clflags" 1>>Volumes.txt

    6095:mminfo: no matches found for the query

    So what I need to know is ... how can I restructure my FOR loop so that the value read from the file doesn't stop at the first space, but instead is the whole line? (or until the delimiter <CR>, I guess). I tried puting a special delimiter character at the end of each entry ("ADMNLTS003\"), but can't seem to figure out how to then strip the delimiter out of the variable ...

    Thanks

  • 12 years ago
    This works:

    FOR /F "DELIMS=/" %%a IN  ....

    This says tho use a different delimiter (rather than a space; I chose a /, but you should be able to choose any character not on your line).

    Then it read the entry, spaces and all ...

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe