0

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?

3
  • What is your question? Commented May 17, 2018 at 2:22
  • How do i run those batch command without getting an error Commented May 17, 2018 at 2:23
  • this is not reproducible for me, I can run those system commands without issue. What shell are you using? Commented May 17, 2018 at 4:50

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @amit , so that progressed a step but now I am getting {1..3} was unexpected at this time
@AutomateFr33k, 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. I have modified above mentioned answer post

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.