I am using Windows 7 Notepad to write a trivial batch file and getting an error message I can't identify or isolate:
REM Robocopy script for Sequoia data collection
REM Run WRITE three times, collect the results
cd c:\Robo_results\Sequoia_tests
for /L %%n in (1, 1, 1) do (
REM WRITE
echo Testing again %%n
)
for /L %%n in (1, 1, 1) do (
echo Pause for 60 seconds until the crawler (hopefully) finishes
)
Output:
c:\Robo_results\Sequoia_tests>run_Seq_robocopy2.bat
c:\Robo_results\Sequoia_tests>REM Robocopy script for Sequoia data collection
c:\Robo_results\Sequoia_tests>REM Run WRITE three times, collect the results
c:\Robo_results\Sequoia_tests>cd c:\Robo_results\Sequoia_tests
c:\Robo_results\Sequoia_tests>for /L %n in (1 1 1) do (
REM WRITE
echo Testing again %n
)
c:\Robo_results\Sequoia_tests>(
REM WRITE
echo Testing again 1
)
Testing again 1
finishes was unexpected at this time.
c:\Robo_results\Sequoia_tests> echo Pause for 60 seconds until the crawler (hopefully) finishes
c:\Robo_results\Sequoia_tests>
I don't understand what "finishes" is referring to. I used a hex editor and see 0D 0A for CR LF, which seem OK.
Interesting: the text I copied from notepad and pasted in this submission have CR and LF but the question as displayed does not. Rephrasing that statement: In the batch file REM and echo start new lines but in this display they do not. Thank you, Neal
finishes
is the word in your batch file having that exact spelling, from here:
for /L %%n in (1, 1, 1) do ( echo Pause for 60 seconds until the crawler (hopefully) finishes )
This has a few parts:
A loop
for /L %%n in (1, 1, 1) do
A subshell, delimited by parentheses ()
A command inside the subshell
echo Pause for 60 seconds until the crawler (hopefully
Some garbage following the close parenthesis:
finishes )
That last part causes an error.
You meant for the first close parenthesis to be part of the message, not end the subshell, but the command interpreter doesn't know that. Try writing your message without using characters ( )
) with special meaning to the shell. Or use some quotes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.