Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Batch file loop and increment value for condition Post 302959187 by cmccabe on Thursday 29th of October 2015 05:03:55 PM
Old 10-29-2015
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 Smilie.

Question 2
Code:
  set /P c=Do you want to send the DOSE report[y/n]?


Batch file as is:
Code:
@ECHO OFF
:: ask user 
 :choice
 set /P c=Has the check been done [y/n]
 if /i %c%==y (
 set /P c=Do you want to send the DOSE report[y/n]?
 ) else (
 if /i %c%==n goto check
 )
 :file
 if /i %c%==y ( 
 "L:\NGS\HLA LAB\total quality management\QC & QA\DOSE reports\DOSE reporting form.xlsm"
 ) else (
 if /i %c%==n goto goodbye
 )
 :check
 set /P c=Do you want to perform the check [y/n]
 if /i %c%==y (
 set /P c=please complete the check and click enter
 goto file
 ) else (
 if /i %c%==n goto goodbye
 )
 :goodbye
echo "goodbye"
TIMEOUT 2 /nobreak
exit

:: count loop
set var1=0
:loop
set /a var1=%var1%+1
if %var1% EQU 1 (
    goto end
) else (
    goto loop
)
:goodbye
echo "goodbye"
TIMEOUT 2 /nobreak
exit
:end
echo "the DOSE report has already been sent by %USERNAME% on %DATE% at   %TIME%"

 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Increment date in 'for' loop?

Hi Guys, My first post..:) Right...I want to move existing files (with some date in their name) currently in $mainftp, to $mainfolder/$foldate/system1. I'd like to be able to increment date in the for loop? Is this possible or should I use a different technique. The script return the... (4 Replies)
Discussion started by: SunnyK
4 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

Increment nested for loop parllely

Hi , I am trying to increment the nested for loops parellely,but i cant ,i used continue 2 but the second loop not getting increment. no1="1 6 5 4 8" no2="4 7 8 0 1" for var1 in $no1 ; do for var2 in $no2 ; do line1 line 2 line 3 continue 2 done done Please help on this (4 Replies)
Discussion started by: nmahendran
4 Replies

5. Programming

[Xquery] How to do a increment in a For loop

Hello men. How can i build a simple increment for $a by Xquery such as ? let $a := 0 for $i in (1 to 10) let $a := $a + 1 return $a why a in this loop always is '1' Thank you for reading, its will really helpful for my job if i can solve this problem :D:D (3 Replies)
Discussion started by: tien86
3 Replies

6. Shell Programming and Scripting

While loop is not reading next line in the file when IF condition is used.

Hi Guys I am new to scripting.Please forgive for asking basic questions. I want to write a script to check whether the logs are getting updated in last 15 mins. cat server 192.168.1.6 192.168.1.7 cat list 192.168.1.7 /logs/logpath1 192.168.1.7 /logs/logpath2 192.168.1.6... (4 Replies)
Discussion started by: vdurai
4 Replies

7. Shell Programming and Scripting

For/While Loop to Increment Filenames in a Script

Daily stupid question. I want to increment the file name everytime the script is run. So for example if the filename is manager.log and I run the script, I want the next sequence to be manager.log1. So to be clear I only want it to increment when the script is executed. So ./script... (10 Replies)
Discussion started by: metallica1973
10 Replies

8. Shell Programming and Scripting

Recursive search for string in file with Loop condition

Hi, Need some help... I want to execute sequence commands, like below test1.sh test2.sh ...etc test1.sh file will generate log file, we need to search for 'complete' string on test1.sh file, once that condition success and then it should go to test2.sh file, each .sh scripts will take... (5 Replies)
Discussion started by: rkrish123
5 Replies

9. Shell Programming and Scripting

Extract batch based on condition

HI, I have a file as mentioned below. Here one batch is for one user id.Batch starts from |T row and ends at .T row. I want to create a new file by reading this file. The condition is for record 10(position 1-2), if position 3 to position 17 is 0 then delete the entire batch and write into the new... (9 Replies)
Discussion started by: abhi.mit32
9 Replies

10. Shell Programming and Scripting

Parallel increment of nested for loop

Hi, I am using solaris 5.10 environment and need help on doing parallel increment of nested for loop. Samples #inside the code the values assigned to a variable by another awk command will be like a=/xyz/pg/as /xyz/pg/as2 /xyz/pg/as3 b=/xyz/sd/fd1 /xyz/sd/fd2 /xyz/sd/fd3 for q in... (1 Reply)
Discussion started by: ananan
1 Replies
VAR_EXPORT(3)								 1							     VAR_EXPORT(3)

var_export - Outputs or returns a parsable string representation of a variable

SYNOPSIS
mixed var_export (mixed $expression, [bool $return = false]) DESCRIPTION
var_export(3) gets structured information about the given variable. It is similar to var_dump(3) with one exception: the returned represen- tation is valid PHP code. PARAMETERS
o $expression - The variable you want to export. o $return - If used and set to TRUE, var_export(3) will return the variable representation instead of outputting it. RETURN VALUES
Returns the variable representation when the $return parameter is used and evaluates to TRUE. Otherwise, this function will return NULL. NOTES
Note When the $return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start(3) callback function. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.0 | | | | | | | Possibility to export classes and arrays con- | | | taining classes using the __set_state() magic | | | method. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 var_export(3) Examples <?php $a = array (1, 2, array ("a", "b", "c")); var_export($a); ?> The above example will output: array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), ) <?php $b = 3.1; $v = var_export($b, true); echo $v; ?> The above example will output: 3.1 Example #2 Exporting classes since PHP 5.1.0 <?php class A { public $var; } $a = new A; $a->var = 5; var_export($a); ?> The above example will output: A::__set_state(array( 'var' => 5, )) Example #3 Using __set_state() (since PHP 5.1.0) <?php class A { public $var1; public $var2; public static function __set_state($an_array) { $obj = new A; $obj->var1 = $an_array['var1']; $obj->var2 = $an_array['var2']; return $obj; } } $a = new A; $a->var1 = 5; $a->var2 = 'foo'; eval('$b = ' . var_export($a, true) . ';'); // $b = A::__set_state(array( // 'var1' => 5, // 'var2' => 'foo', // )); var_dump($b); ?> The above example will output: object(A)#2 (2) { ["var1"]=> int(5) ["var2"]=> string(3) "foo" } NOTES
Note Variables of type resource couldn't be exported by this function. Note var_export(3) does not handle circular references as it would be close to impossible to generate parsable PHP code for that. If you want to do something with the full representation of an array or object, use serialize(3). Warning When var_export(3) exports objects, the leading backslash is not included in the class name of namespaced classes for maximum com- patibility. SEE ALSO
print_r(3), serialize(3), var_dump(3). PHP Documentation Group VAR_EXPORT(3)
All times are GMT -4. The time now is 08:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy