Quote:
Originally Posted by oracleguy
I'd be remiss if I didn't ask why oh why you are using batch files?
|
Hah, yep.
Its for an automated recovery job creation with our ARCServe software. We found out that doing a recovery by tree takes the information at job creation time, and not runtime, so we couldn't schedule it to run day by day (every day will try to use the same session and tape to recover instead of the newest one to move into recovery domain which is what we need). Instead, we can link .bat scripts into post execute commands for the job we want to do automatic recovery on and create the restore every day. Alternatives do include .exe files, but I'm pretty sure that my department probably won't be happy with compiled programs to run on this (hence why I chose the batch file route instead). A big part of it is because I will be leaving the group I'm in soon; I took a position as an IIS administrator (the Systems guys are a little sad

). I wanted to make sure I wrote something that everyone else can easily modify, with as much room for growth as possible (which is why I'm doing the switches.txt file instead of embedding the commands directly in the batch script). Current format of the switches file:
Code:
CAHOST="OURHOST"
SOURCE="OUR SOURCE AND PATH"
USERNAME="OURUSERNAME"
HOLD
And so forth, and I need it to essentially become:
Code:
:: ca_restore is the command line arcserve restore creation application
ca_restore -cahost "OURHOST" -source "OUR SOURCE AND PATH" -username "OURUSERNAME" -hold
Quote:
Originally Posted by Spookster
How about
Code:
@ECHO OFF
SetLocal EnableDelayedExpansion
FOR /F "tokens=1,2 delims=," %%i IN (switches.txt) DO (
SET SWITCHES=!SWITCHES! %%i %%j
)
ECHO %SWITCHES%
PAUSE
EXIT
|
Oh yeah, delayed expansions! I should have noted that my delimiter is actually an = sign, but that isn't really a huge deal. I don't remember the last time I used one of those O.o
I guess it wouldn't really matter either if the second parameter is empty. All you end up with is an empty space in worst case scenario which (I assume it will be anyway) be ignored by the the arcserve command app. I have an all day conference at work today, but I'll drop by after and try this out to see how it goes - I'll let you know, thanks spooks!
Edit:
Thanks a lot spooks, worked like a charm!