Batch file question

Networking/Security Forums -> Programming and More

Author: Sgt_BLocation: Chicago, IL US PostPosted: Wed Nov 20, 2002 7:18 pm    Post subject: Batch file question
    ----
We have a script that runs, and we want to write the output of that batch file into a log file. As of right now the script runs, and writes to the log file. We'd like to have the script create a new file if previous log file exists.
Example:
Script runs, writes to log.log
Script runs again, sees that log.log already exists, so it writes to log1.log (log2.log, log3.log etc.)

What can I do to get this done?

Thanks!

Running NT SP6a.

Author: TheKingsterLocation: UK PostPosted: Wed Nov 20, 2002 7:22 pm    Post subject:
    ----
%logfile% = log.log
if exist %logfile% then %logfile% = log1.log

THEN PUT


>> %logfile% at the end of the lines you want to log to.

The first line has to be > though so it creates the new file as >> is append to the end.

Author: ShaolinTigerLocation: Kuala Lumpur, Malaysia PostPosted: Wed Nov 20, 2002 7:29 pm    Post subject:
    ----
Yeh and do it like log1.log to log9.log, then if log9.log exists
zip.exe log1.log, log2.log, log3.log etc to %DATE%-archive.zip or something like that.

Then it will continuosly run without taking up too much space and will archive all old logs in a neat zip file.

Author: browolf PostPosted: Fri Nov 22, 2002 7:08 pm    Post subject:
    ----
Sgt_B wrote:
Hey thanks alot! I like the zip thing...didn't even cross my mind. Very Happy


have u thought of using wsh?
possibilities abound with more power.


~andy

Author: ShaolinTigerLocation: Kuala Lumpur, Malaysia PostPosted: Fri Nov 22, 2002 7:08 pm    Post subject:
    ----
Or even better kixstart apparently...

Author: Sgt_BLocation: Chicago, IL US PostPosted: Fri Nov 22, 2002 11:44 pm    Post subject:
    ----
C1 - No not CW.

ST - We have kixstart, but I have no idea what to do with it. Logon scripts are as far as I've gotten. Very Happy I have the manual in my desk somewhere though...collecting dust no doubt.

Browulf - Whats wsh? Haven't heard of it before.

Author: hadsLocation: New Zealand PostPosted: Mon Nov 25, 2002 4:02 am    Post subject:
    ----
WSH == Windows Script Host

i.e. Scripting using VBScript or Javascript. Whist running under the script host they have vastly more power than when used for the web (thank f**k) e.g. Network operations, File operations etc. etc.

/edit: Need to go to spelling school


Last edited by hads on Mon Nov 25, 2002 11:07 am; edited 1 time in total

Author: enigmanLocation: Sydney PostPosted: Mon Nov 25, 2002 10:32 am    Post subject:
    ----
hads wrote:
WSH == Windows Script Host

i.e. Scripting using VBScript of Javascript. Whist running under the script host they have vastly more power than when used for the web (thank f**k) e.g. Network operations, File operations etc. etc.


Too right it's got more power. I wrote a WSH/HTML app for our Win2K rollout that enumerated the printers for our different sites, gave the user a list of printers to choose from then would map the printers for them.

We don't use it for login scripts as most of our admins are more familiar with batch files, KixTart etc than VBScript etc.

Enigman
----------
Do the voices in my head bother you?



Networking/Security Forums -> Programming and More


output generated using printer-friendly topic mod, All times are GMT + 2 Hours

Page 1 of 1

Powered by phpBB 2.0.x © 2001 phpBB Group