neticsplanwan
IS-IT--Management
I have a server that generates log files from Internet Information Server for website reporting purposes. These log files are saved in d:\logfiles\w3svc*. There are currently 103 w3svc folders with logfiles. The files saved in this folder are saved in ex year/month format (ex0503 - The year 2005 in March). These reports are generated monthly. The log files get pretty big so I have to zip up the log files monthly to save disk space. So, what I am trying to accomplish is to write a program that automatically zippes up the exmonthdate files within the w3svc folders. Then copies the zip files to another server on the network. Next deletes the zipped and the .log files from the source. Here is what I have:
QBASIC Program that automatically zippes the files called test2.
CLS
FOR i = 1 to 200
PRINT "Zipping d:\logfiles\w3svc" + LTRIM$(STR$(i))
CHDIR d:\logfiles\w3svc" + LTRIM$(STR$(i))
SHELL "PKZIP d:\logfiles\w3svc" + LTRIM$(STR$(i)) + "\ex0503.zip" d:\logfiles\w3svc" + LTRIM$(STR$(i)) + "\ex0503.log"
NEXT i
The program works but once it get to the last w3svc it just displays "Path Not Found" when its done. I think I need to set some sort of loop b/c the number of w3svc folder is always changing.
Then once that is done I run the copyit.bat which contains this code:
@echo off
rem COPYIT.BAT transfers all files in all subdirectories of
rem the source drive or directory (%1) to the destination rem drive or directory (%2)
xcopy d:\logfiles\*.zip p:\logfiles\test /s /e
if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit
:lowmemory
echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit
:abort
echo You pressed CTRL+C to end the copy operation.
goto exit
:exit
This program works very nice.
Then once that is done I run the delete.bat which contains the code:
cd\
d:
del d:\logfiles\*.zip
del d:\logfiles\*ex0503*
What I should do is combine all these functions into one program. Then run a scheduled task every month on the server. I don't know how to fix my loop issue in the qbasic program and call the batch files within QBASIC. Can someone help?
QBASIC Program that automatically zippes the files called test2.
CLS
FOR i = 1 to 200
PRINT "Zipping d:\logfiles\w3svc" + LTRIM$(STR$(i))
CHDIR d:\logfiles\w3svc" + LTRIM$(STR$(i))
SHELL "PKZIP d:\logfiles\w3svc" + LTRIM$(STR$(i)) + "\ex0503.zip" d:\logfiles\w3svc" + LTRIM$(STR$(i)) + "\ex0503.log"
NEXT i
The program works but once it get to the last w3svc it just displays "Path Not Found" when its done. I think I need to set some sort of loop b/c the number of w3svc folder is always changing.
Then once that is done I run the copyit.bat which contains this code:
@echo off
rem COPYIT.BAT transfers all files in all subdirectories of
rem the source drive or directory (%1) to the destination rem drive or directory (%2)
xcopy d:\logfiles\*.zip p:\logfiles\test /s /e
if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit
:lowmemory
echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit
:abort
echo You pressed CTRL+C to end the copy operation.
goto exit
:exit
This program works very nice.
Then once that is done I run the delete.bat which contains the code:
cd\
d:
del d:\logfiles\*.zip
del d:\logfiles\*ex0503*
What I should do is combine all these functions into one program. Then run a scheduled task every month on the server. I don't know how to fix my loop issue in the qbasic program and call the batch files within QBASIC. Can someone help?