0

I need some help. I want to execute for loop with if-else statement but i got some error. This is my code

mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" | FOR /F %%D IN ('C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))

The output is

< was unexpected at this time
8
  • does any of your strings contain "<" . LIke %pathx% ? Commented Feb 11, 2015 at 6:30
  • Please show a sample output from the mysql command Commented Feb 11, 2015 at 6:32
  • it does not contain. SET path=C:\Users\neca\Desktop thats it sir. @npocmaka Commented Feb 11, 2015 at 6:53
  • this is just the output sir. < was unexpected at this time @Magoo Commented Feb 11, 2015 at 6:53
  • You are piping the output of the mysql command mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" into a for/f command. I've asked for a sample output of that mysql command. Commented Feb 11, 2015 at 7:22

1 Answer 1

1

Your error report is incorrect. The output you are receiving is

( was unexpected at this time

You can't validly pipe output into a for statement. Change your code to

FOR /F %%D IN ('mysql -u%UserName% -N -B -e "SHOW DATABASES LIKE '%%sample%%';" ^| C:\Windows\System32\findstr /V "information_schema performance_schema"') DO (IF EXIST %pathx%\%%D (echo test) ELSE (echo fail))
Sign up to request clarification or add additional context in comments.

Comments

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.