Results 1 to 4 of 4
I am in the process of building a front-end for an e-commerce site. It downloads xml files from one of my distributors which I parse and load into an mysql ...
- 08-29-2008 #1Just Joined!
- Join Date
- Aug 2008
- Posts
- 2
How to exec php scripts from php or bash
I am in the process of building a front-end for an e-commerce site. It downloads xml files from one of my distributors which I parse and load into an mysql database. It is then all sanitized and then imported into the Web Site. The process requires running a lot of individual php scripts one after the other which will be set off via a cron job. My problem is what process to use to pull this off.
1. A php script which uses exec() or shell_exec() to start the first script in the process, if the child process returns an exit code of 0 then I need to start the second script and so on.
2. Do the same process as above but use a bash script to execute each php script. The best info I could find on bash was bits and pieces I found in the manual.
I have spent quite a few days looking at both possibilities and am stuck. I have heard a lot of negatives about spanning php scripts from a php script using exec. This is my first choice because I'm familiar with PHP (beginner/intermediate) but have not been able to get it to run yet.
I have been trying for days to find some good info on writing a bash script to do the job, but haven't had any luck. Can anyone point me in the right place? I am a total beginner with bash but assume it is the best to use.
#!/bin/bash
#test.sh
php MyStartPgm.php echo $?
wait
if return_code == 0
php MyNextPgm.php echo $?
else
exit(1)
Any code examples would be greatly appreciated.
Thanks in advance for any help!
- 09-02-2008 #2Just Joined!
- Join Date
- Aug 2008
- Location
- London, UK
- Posts
- 13
I am thinking of something similar and my only warning to this is not to use a unverified cron job to do it at all.
It is much safer if you can log in and execute the loading when you desire, as this is something you dont want to risk messing up your price lists, item lists and more.
Imagine just one itme being malformed and putting it up at a price $0.45 when it should be $450.00
I would not dare risk it, personally nor for a clients shop.
- 09-02-2008 #3Just Joined!
- Join Date
- Aug 2008
- Posts
- 2
Thanks for your reply. You have a good point. Even though this is my own site I'm checking everything coming in and verifying all of the data field by field. If anything changes or is to be added I create a journal which I will manually check before I do the final import into my site. Even the data download is logged and if anything unusual happens It sends me an e-mail and doesn't continue with out my intervention.
Have you heard of any problems using a PHP script to exec other PHP programs? People have made comments but haven't had any conversing arguments.
Jim
- 09-02-2008 #4Just Joined!
- Join Date
- Aug 2008
- Location
- London, UK
- Posts
- 13
I have had some problems but mostly on servers not running Apache. Such as that PHP suddenly crashed my entire MySQL setup.
I had one server ending up completely corrupted and I had to reinstall MySQl from scratch because of it.
In OSCommerce cart I have experienced extremely slow load times in phpMyAdmin towards it as well, but mostly when calling for the database structure. OSCommerce have also crashed several times in the previous site we ran so i desided to create my own from nothing instead.
Also, only because it works on one box doesnt mean it will work on another. It could be as simple a glitch as a minor change in the ini file to either of the two mentioned to cause major differences in behaviour.


Reply With Quote