Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Loop statement within a batch script Post 303002078 by HenkTrumpie on Thursday 17th of August 2017 05:22:52 AM
Old 08-17-2017
Hammer & Screwdriver Loop statement within a batch script

I have to create a couple of files within a directory structure.
Filename stays the same, but at the end of each file, the number appears.

Example:
File needs to be created within directory c:\temp
File Name will stay the same (testfile), but extension will increase, starting at 01 - example - testfile01, testfile02, ....

Depending on the day of the month, I will either create 10 files or I will create 26 files or 53, number can very.

Directory will look something like this:
Code:
c:\temp
testfile01
testfile02
testfile03.....
testfile10 or 16 or 43 or 32

The value I will change daily

Can anyone help me with a script for this please?

Last edited by rbatte1; 08-17-2017 at 08:40 AM.. Reason: Added CODE tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if statement in a while loop

#!/usr/bin/ksh echo Please enter while read n do echo $n >> datafile done question: How can I enject an if statement that if the users enter 0 (zero) the program will exit? this is what I have but not working #!/usr/bin/ksh echo Please enter number while read n do if $n=0 then... (2 Replies)
Discussion started by: bobo
2 Replies

2. Shell Programming and Scripting

SSH in batch mode and File-Handles in a loop

Hi all I try to execute SSH commands on several hosts in a while-loop. There seems to be a problem with file-handle, first cycle works correct but no other one will follow due to the while condition is false even that there are many more host entries (lines) in all_hosts.dat. ... (3 Replies)
Discussion started by: DaveCutler
3 Replies

3. Shell Programming and Scripting

running a batch file in loop

i have a batch file which should run every five min...for an hour can any one help me out (1 Reply)
Discussion started by: aemunathan
1 Replies

4. Shell Programming and Scripting

Help with IF statement with loop Shell Script

Hello I am very new to shell and I bought some books and trying to learn it. I started trying to write a script that will take a number and count it down to 1 with commas in between. This number can only be one argument. If lower than one or higher than one argument it sends an error message. ... (4 Replies)
Discussion started by: zero3ree
4 Replies

5. Shell Programming and Scripting

Help With Loop in Case Statement script

I am writing a bash script that asks the user for input and I need it to repeat until the user selects quit.. I dont know how to write the loop for it I searched all over but i still do not get it.. if anyone could help with this it would be greatly apprciated here is my script so far: #!... (2 Replies)
Discussion started by: Emin_Em
2 Replies

6. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

7. Shell Programming and Scripting

how to create a loop in an if statement

Hey guys, a=`cat abc | wc -l` b=`cat def | wc -l` if $a== $b then echo "a" else echo "b" fi I want the if condition to retry itself , untill a==b. I can't use goto statemt. Please help. Thanx in advance. Please use next time code tags for your code and data (5 Replies)
Discussion started by: jaituteja
5 Replies

8. Shell Programming and Scripting

awk if statement in a for loop?

I need to match multiple values in a single column in a file: example: Source file: abd,123,one def,232,two ghi,987,six Target file: 12345,abcde,123 09876,zxvyr,566 56789,lmnop,232 Variable: var1=`grep 2 sourcefile | awk '{print$1}' essentially, echo "$var1" would read:... (2 Replies)
Discussion started by: kopfgeldjagar
2 Replies

9. Shell Programming and Scripting

While loop within if statement

Hi, I'm a rookie who is trying to learn this stuff. What I need help with is putting together a non complicated "while" loop within the below "if" statement. I also need the while loop to keep looping until the user types a key to end the loop. Please reveal the proper insertion points. Thank... (4 Replies)
Discussion started by: jefferj54
4 Replies

10. Windows & DOS: Issues & Discussions

Batch file loop and increment value for condition

I am trying to have the below batch file do following two things: 1. only allow the values YES,yes,Y,y, or NO,no,N,n 2. increment the counter %var1 only if answer to question 2 is "y" and not able to get the syntax correct. If %var1%=1 then I am trying to display function :end. Thank you :).... (0 Replies)
Discussion started by: cmccabe
0 Replies
DBCHECK(8)					     Network backup, recovery and verification						DBCHECK(8)

NAME
dbcheck - Bacula's Catalog Database Check/Clean program SYNOPSIS
dbcheck [options] working-directory bacula-database user password [dbhost] [dbport] DESCRIPTION
This manual page documents briefly the dbcheck command. dbcheck will not repair your database if it is broken. Please see your vendor's instructions for fixing broken database. dbcheck is a simple program that will search for logical inconsistencies in the Bacula tables in your database, and optionally fix them. It is a database maintenance routine, in the sense that it can detect and remove unused rows, but it is not a database repair routine. To repair a database, see the tools furnished by the database vendor. Normally dbcheck should never need to be run, but if Bacula has crashed or you have a lot of Clients, Pools, or Jobs that you have removed, it could be useful. OPTIONS
A summary of options is included below. -? Show version and usage of program. -b If specified, dbcheck will run in batch mode, and it will proceed to examine and fix (if -f is set) all programmed inconsistency checks. By default, dbcheck will enter interactive mode (see below). -C catalog catalog name in the director conf file. -c config If the -c option is given with the Director's conf file, there is no need to enter any of the command line arguments, in particular the working directory as dbcheck will read them from the file. -B print catalog configuration and exit. -d nn set debug level to nn. -dt print timestamp in debug output. -f If specified, dbcheck will repair (fix) the inconsistencies it finds. Otherwise, it will report only. -v Set verbose mode. INTERACTIVE MODE
In interactive mode dbcheck will prompt with the following: Hello, this is the database check/correct program. Please select the function you want to perform. 1) Toggle modify database flag 2) Toggle verbose flag 3) Repair bad Filename records 4) Repair bad Path records 5) Eliminate duplicate Filename records 6) Eliminate duplicate Path records 7) Eliminate orphaned Jobmedia records 8) Eliminate orphaned File records 9) Eliminate orphaned Path records 10) Eliminate orphaned Filename records 11) Eliminate orphaned FileSet records 12) Eliminate orphaned Client records 13) Eliminate orphaned Job records 14) Eliminate all Admin records 15) Eliminate all Restore records 16) All (3-15) 17) Quit Select function number: By entering 1 or 2, you can toggle the modify database flag (-f option) and the verbose flag (-v). It can be helpful and reassuring to turn off the modify database flag, then select one or more of the consistency checks (items 3 through 9) to see what will be done, then toggle the modify flag on and re-run the check. The inconsistencies examined are the following: Duplicate filename records. This can happen if you accidentally run two copies of Bacula at the same time, and they are both adding filenames simultaneously. It is a rare occurrence, but will create an inconsistent database. If this is the case, you will receive error messages during Jobs warning of duplicate database records. If you are not getting these error messages, there is no reason to run this check. Repair bad Filename records. This checks and corrects filenames that have a trailing slash. They should not. Repair bad Path records. This checks and corrects path names that do not have a trailing slash. They should. Duplicate path records. This can happen if you accidentally run two copies of Bacula at the same time, and they are both adding filenames simultaneously. It is a rare occurrence, but will create an inconsistent database. See the item above for why this occurs and how you know it is happening. Orphaned JobMedia records. This happens when a Job record is deleted (perhaps by a user issued SQL statement), but the corresponding JobMedia record (one for each Volume used in the Job) was not deleted. Normally, this should not happen, and even if it does, these records generally do not take much space in your database. However, by running this check, you can eliminate any such orphans. Orphaned File records. This happens when a Job record is deleted (perhaps by a user issued SQL statement), but the corresponding File record (one for each Volume used in the Job) was not deleted. Note, searching for these records can be very time consuming (i.e. it may take hours) for a large database. Normally this should not happen as Bacula takes care to prevent it. Just the same, this check can remove any orphaned File records. It is recommended that you run this once a year since orphaned File records can take a large amount of space in your database. You might want to ensure that you have indexes on JobId, FilenameId, and PathId for the File table in your catalog before running this command. Orphaned Path records. This condition happens any time a directory is deleted from your system and all associated Job records have been purged. During standard purging (or pruning) of Job records, Bacula does not check for orphaned Path records. As a consequence, over a period of time, old unused Path records will tend to accumulate and use space in your database. This check will eliminate them. It is recommended that you run this check at least once a year. Orphaned Filename records. This condition happens any time a file is deleted from your system and all associated Job records have been purged. This can happen quite frequently as there are quite a large number of files that are created and then deleted. In addition, if you do a system update or delete an entire directory, there can be a very large number of Filename records that remain in the catalog but are no longer used. During standard purging (or pruning) of Job records, Bacula does not check for orphaned Filename records. As a consequence, over a period of time, old unused Filename records will accumulate and use space in your database. This check will eliminate them. It is strongly recommended that you run this check at least once a year, and for large database (more than 200 Megabytes), it is probably better to run this once every 6 months. Orphaned Client records. These records can remain in the database long after you have removed a client. Orphaned Job records. If no client is defined for a job or you do not run a job for a long time, you can accumulate old job records. This option allow you to remove jobs that are not attached to any client (and thus useless). All Admin records. This command will remove all Admin records, regardless of their age. All Restore records. This command will remove all Restore records, regardless of their age. By the way, I personally run dbcheck only where I have messed up my database due to a bug in developing Bacula code, so normally you should never need to run dbcheck inspite of the recommendations given above, which are given so that users don't waste their time running dbcheck too often. SEE ALSO
bls(1), bextract(1). AUTHOR
This manual page was written by Jose Luis Tallon <jltallon@adv-solutions.net>. Kern Sibbald 26 September 2009 DBCHECK(8)
All times are GMT -4. The time now is 06:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy