Thursday, November 22, 2012

create a bash script to run php files

I have create this shell script to migrate  customer, address and orders. 


1st must migrate customer
2nd migrate addresses
3rd migrate order

this 3 tasks i can do by running 1 script when i create bash file.

order_create_shellScript.sh


#!/bin/sh

# Author Sanjeewani
# Date 2012-11-06

# Shell script to migrate Proporta customer,customer address, orders to magento via php scripts


# /team/project_mojo/sourcecode/migration_script_v01/deploy_notes/customer_create_deploy_note.txt
# /team/project_mojo/sourcecode/migration_script_v01/deploy_notes/order_create_deploy_note.txt

path=`pwd`
logfile=$path/../log/order_create_shellScript.log

cd $path
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Starting to migrate orders" | tee -a $logfile

# 1- Script for migrate all customers with all direct attributes
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Migrating all customers with all direct attributes" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php customer_create.php -nor 5000" | tee -a $logfile
php customer_create.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate all customers with all direct attributes" | tee -a $logfile

# 2- Script for update customers(fix to first name and last name)
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> updating migrated customers" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php customer_update.php -nor 5000" | tee -a $logfile
php customer_update.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished update customers" | tee -a $logfile

# 3- Script for migrate customer addresses
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Migrating  customer addresses  " | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php customer_create_address.php -nor 700000" | tee -a $logfile
php customer_create_address.php -nor 700000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate all addresses" | tee -a $logfile

# 4-Script for Migrate missing addresses(for old migrated customer's latest addresses)
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Migrating missing addresses" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php customer_create_missing_address.php -nor 5000" | tee -a $logfile
php customer_create_missing_address.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate missing addresses" | tee -a $logfile

# 5- Script for update customer addresses
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> updating customer addresses" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php customer_address_update.php -nor 5000" | tee -a $logfile
php customer_address_update.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished update customer addresses" | tee -a $logfile

# 6- Script for reassign store view to customers
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> updating customer store view" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php customer_reassign_storeview.php -nor 5000" | tee -a $logfile
php customer_reassign_storeview.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished update customer store view" | tee -a $logfile

# 7- Script for migrate orders
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Migrating orders" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php order_create.php -nor 5000" | tee -a $logfile
php order_create.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate orders" | tee -a $logfile

# 8- Script for migrate missing orders
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Migrating Missing orders" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php order_create_missing.php -nor 5000" | tee -a $logfile
php order_create_missing.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate missing orders" | tee -a $logfile

# 9- Script for update currency rate for orders
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> updating currency rate for orders" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php order_update_currency_rate.php -nor 5000" | tee -a $logfile
php order_update_currency_rate.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate all customers with all direct attributes" | tee -a $logfile

# 10- Script for migrate order notes for migrated orders
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Migrating order notes" | tee -a $logfile
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  -->\t running php order_note_create.php -nor 5000" | tee -a $logfile
php order_note_create.php -nor 5000
echo "`date +"%Y-%m-%d %H:%M:%S"` - INFO  --> Finished migrate order notes" | tee -a $logfile


echo "--------------------------------------------------------" | tee -a $logfile






No comments:

Post a Comment