Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

CRON Automatic EasyPopulate import


Recommended Posts

I've seen a few other people looking for the same solution, to I thought I'd wake it back up. If anyone else needs the same, could you add a reply to this post.



Is it not possible to run a CRON job to import the file at a certain time? I don't have to use phpjob scheduler. I have a very limited understanding of PHP and SQL but the code needed to import that file must be in the Easy populate file already.


I would just like a way for oscommerce to automatically import updated inventory files that I can create and FTP to my webserver.


Is anybody already doing this?


I'm willing to share it with others if I can get a cron job to automate the imports instead of having to go into the admin tool.


Easy Populate is in the admin section and that is pasword protected. Is there a way around that?



Using a CRON task to automatically run EasyPopulate imports


Our stock files are uploaded, pre-split, by a stock control system we have developed. It'd be great if the site were to run the import silently, so you dont need to log in to admin and run the import x number of times.


My attempts so far


I have tried to get this working using a cron task to automatically run EasyPopulate every 10 mins, but only if a certain file has been uploaded. This means that we upload files stock1, stock2, stock3 and a file called Doimport. The cron task runs a script, the script will then execute a SHELL SCRIPT (subtly different to perl)


0,10,20,30,40,50 * * * * /usr/local/psa/home/vhosts/website.co.uk/cgi-bin/update 2>&1 >/dev/null


update script file:

[ -e /usr/local/psa/home/vhosts/website.co.uk/httpdocs/catalog/temp/Doimport ] || exit
rm /usr/local/psa/home/vhosts/website.co.uk/httpdocs/catalog/temp/Doimport
echo "<CONTENT-TYPE: text/html>"
echo ""
echo "<HTML><BODY><H1>DONE</H1>"
for I in `ls /usr/local/psa/home/vhosts/website.co.uk/httpdocs/catalog/temp/osc*`
echo "$I $T"
echo "<BR>"
wget --output-document=- --timeout=300 --http-user=username --http-passwd=password http://www.website.co.uk/catalog/admin/easypopulate.php?localfile=$T&buttoninsert=INSERT_INTO_DB 2>&1 > /dev/null
echo "</BODY></HTML>"


To paraphrase, for each file matching the name osc*, run the easypopulate script for the file. This operates only if the Doimport file exists. Doimport is then deleted, so the script doesn't run in another 10 mins.


Importantly, wget allows us to 'log in' to admin


Problem is,

A ) the script will run the import for stock1, stock2 etc all at the same time, so the server gets tied up trying to do all the imports symultaneously, the site slows to a crawl and none of the imports happen. The error log eventually says 'giving up' for each file.

B ) The user gets no feedback if imports fail. An email would be nice!


Anyone else looking for similar functionality? If you could try the above and let me know if you have any successes, also record how many product lines were imported, how many split files you had etc.


Also, anyone else after the same solution please register your interest!




Matt Brown

btw, I have posted the request on the EP V3 requests list at http://www.oscommerce.com/forums/index.php?showtopic=153115.

Link to comment
Share on other sites

  • 2 years later...

If you have both password schemes going: .htaccess and the regular login - or you happen to be using OSCMax like I am you're going to run into some problems.


Here is the solution: we're going to make wget store session cookies and run two "gets" - one to authenticate the first time and one to do the easy populate.



wget --cookies=on --keep-session-cookies --save-cookies=cookie.txt --http-user=**HTACCESSUSER** --http-passwd=**HTACCESSPASS** --post-data="email_address=**ADMINEMAIL**&password=**ADMINPASS**" --no-check-certificate https://www.yoursite.com/admin/login.php?action=process


wget --referer=https://www.yoursite.com/admin/login.php?action=process --cookies=on --load-cookies=cookie.txt --keep-session-cookies --save-cookies=cookie.txt --http-user=**HTACCESSUSER** --http-passwd=**HTACCESSPASS** --post-data="localfile=EP_Joined.txt&buttoninsert=Insert%20into%20db" --no-check-certificate https://www.yoursite.com/admin/easypopulate.php


I didn't set the "delete after" flag so that I can pull down the file, rename it to results.html and open it in a web browser to make sure every thing's working.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
  • 11 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...