Tuesday, August 10, 2010

Cross domain data exchange

You can use XML language to transfer large data from one domain to other. Suppose domain-x wants to send data from its database to domain-y. Then domain-x will generate xml file for the database and send it to the domain-y via post method for security purpose. Upon receipt of xml file from domain-x, the domain-y will store that xml file in one folder and create one new row in received_xml table, and call a xmlparser script through cron job to extract information from the xml files and store in database and then move that parsed xml file to some other folder(named like parsed) and remove the record from receive_xml table.

For parsing there are so many free scripts available in php,ruby etc., xmltoarray is one of the technique.


Cron job commands to run shell script, ruby script and php script

Cron job commands to run different Scripts

Syntax:
Time to run - Command
[ Minute - Hour - Day - Month - Weekday ] - Command

Times pattern
* * * * * => Execute every minute
0 * * * * => Execute every Hour
0 0 * * * => Execute every mid-night
0 0 0 * * => Execute every Month
0 0 0 0 * => Execute every Weekday
*/5 * * * * => Execute every 2 minutes
0 */2 * * * => Execute two Hours

Commands can be broken down as
[PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]

######Run PHP Script#########
/usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php

######Run Ruby Script#########
#Ruby cron job setting. Ruby will run cron jobs through script runner.
/usr/local/bin/ruby /home/inkkdds1/inkakinada/script/runner /home/inkkdds1/inkakinada/app/cron_job_database.rb
#ruby-path script-runner-path ruby-file-path

######Run Shell Script#########
cd /home/devinka/public_html/spocosy/ && sh cron.xmlParse.sh
#cd to application-path && sh shell-script-path


Linux Shell Scripting Secrets