How to run several yiic commands in one .bat file?

132 views Asked by At

I have an ImportCommand class which reads a file and imports the data from that file to a database. The command itself works fine.

However, I need to run the same command several times with different files.

My .bat file:

@echo off
cd c:\xampp\htdocs\mysite\protected\
yiic import c:\sourcefiles\users_1.csv
yiic import c:\sourcefiles\users_2.csv
yiic import c:\sourcefiles\users_3.csv

The first command runs then the script stops and files users_2.csv and users_3.csv are not processed.

3

There are 3 answers

0
boliviandev On BEST ANSWER

After struggling with this for a while, I found this answer: How to run multiple .BAT files within a .BAT file

So the .bat file should be:

@echo off
cd c:\xampp\htdocs\mysite\protected\`
call yiic import c:\sourcefiles\users_1.csv
call yiic import c:\sourcefiles\users_2.csv
call yiic import c:\sourcefiles\users_3.csv 
0
LS_ᴅᴇᴠ On

Use CALL command. Without CALL, control is transferred to other batch and is not returned.

0
Kevin Florenz Daus On

Try this

@echo off
cd c:\xampp\htdocs\mysite\protected\
yiic import c:\sourcefiles\users_1.csv && yiic import c:\sourcefiles\users_2.csv && yiic import c:\sourcefiles\users_3.csv

This will execute the desired command one by one . It only proceeds one operation is successful.