Reputation: 602
I have a spec file with the following code and i run it using rake
describe 'Running Reselience test', test_execute: true do
it "running deploy build access service and manage" do
system("for i in {1..3}; do sleep 5; echo $i; done &")
system("for i in {10..13}; do sleep 5; echo $i; done &")
end
end
I am getting the following error in command line when i run the above spec file
i was unexpected at this time.
i was unexpected at this time.
How do i run the above batch commands without getting the above error?
Upvotes: 0
Views: 1446
Reputation: 482
As per the https://superuser.com/questions/894475/for-do-command-gives-was-unexpected-at-this-time-when-run-from-command-prompt URL author mentioned
When referencing For loop variable within a batch file you need to double up the percent signs (ie: %%a), but if you do this when just running the command straight at the prompt it won't work. You need to change them to a single percent sign (%a).
Also in this URL single line for statement: %%i 'unexpected at this time' The author mentioned using a single percent sign
I am using the Linux OS (so can't test your scenario) but as per the below links you need to change your command syntax
URL https://www.windows-commandline.com/windows-for-loop-examples/
URL DOS FOR loop on range through command line
URL https://ss64.com/nt/for_l.html
For example
for %i in (user1 user2 user3 user4 user5 user6) do net user /delete %i
so in your case
FOR /l %i in (1,1,3) DO sleep 5 & echo %i
Upvotes: 1