Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

qbasic zip log files program help

Status
Not open for further replies.

neticsplanwan

IS-IT--Management
Apr 2, 2005
1
US
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?
 
the path not found may be the result of the file not being found.

You could open the file in binary mode, check the lof, close the file then if > 0 then continue with the zip. otherwise it should go to the next number and check for that file.

you could call the qbasic program in the bat file (as well as the delete bat file.

Or get powerbasic for windows and zlib and do it all within
the program.
 
There is a QBasic library called ADVBAS that includes the command
'IF EXIST'
That allows you to check if a file exists. You could include that in your loop to get out when there were no more files.

You can download it from here as ADVBAS.ZIP
 
You're asking:

how to fix my loop issue in the qbasic program and call the batch files within QBASIC.

This is a two-fold question:

Part one: looping issue
What you are asking is/has been covered in several other posts. From adding a variable--so you can adjust the 200 limit to Self-counting submodulized code. I'd suggest you use the Search capabilities on this site to help you find what you are looking for.

Part two: calling a batch file
You already have the basics for the appropriate code in your loop...suggest you use the QB Help files and read up on the SHELL command again. Apparently, you didn't quite understand this command, but yet you know how to utilize it for an outside program. Again I'd suggest you re-read your help files.



Otherwise, if you have specific code that is giving you a serious problem, then please post again.

--MiggyD

--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top