View previous topic :: View next topic |
Author |
Message |
Sgt_B Trusted SF Member
Joined: 28 Oct 2002 Posts: 16777215 Location: Chicago, IL US
|
Posted: 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.
|
|
Back to top |
|
|
TheKingster Link Spammer
Joined: 03 May 2002 Posts: 0 Location: UK
|
Posted: 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.
|
|
Back to top |
|
|
ShaolinTiger Forum Fanatic
Joined: 18 Apr 2002 Posts: 16777215 Location: Kuala Lumpur, Malaysia
|
Posted: 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.
|
|
Back to top |
|
|
browolf Trusted SF Member
Joined: 19 Apr 2002 Posts: 1
|
Posted: 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. |
have u thought of using wsh?
possibilities abound with more power.
~andy
|
|
Back to top |
|
|
ShaolinTiger Forum Fanatic
Joined: 18 Apr 2002 Posts: 16777215 Location: Kuala Lumpur, Malaysia
|
Posted: Fri Nov 22, 2002 7:08 pm Post subject: |
|
|
Or even better kixstart apparently...
|
|
Back to top |
|
|
Sgt_B Trusted SF Member
Joined: 28 Oct 2002 Posts: 16777215 Location: Chicago, IL US
|
Posted: 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. I have the manual in my desk somewhere though...collecting dust no doubt.
Browulf - Whats wsh? Haven't heard of it before.
|
|
Back to top |
|
|
hads Trusted SF Member
Joined: 23 May 2002 Posts: 3 Location: New Zealand
|
Posted: 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 |
|
Back to top |
|
|
enigman Just Arrived
Joined: 09 Oct 2002 Posts: 0 Location: Sydney
|
Posted: 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?
|
|
Back to top |
|
|
|