CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Running bin/UpdateAddress.php from command line to geocode
Pages: [1]

Author Topic: Running bin/UpdateAddress.php from command line to geocode  (Read 2206 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Running bin/UpdateAddress.php from command line to geocode
June 03, 2011, 10:00:41 am
Hey there,

I have a problem (maybe specific to my set up and if that is the case, then the first lot of info in quotes below should help).

Quote
I have my civicrm codebase at /clients/demo/git/drupal/sites/all/modules/civicrm
/clients/demo/git/drupal is linked to /var/www/demo/

Running

ubuntu@colombia:/var/www/demo/sites/all/modules/civicrm/bin$ sudo php UpdateAddress.php -nxxx -pxxx -kxxx

gives the following error:
Quote
<br />Sorry, could not able to locate bootstrap.inc.
(which seems to come from CRM/Utils/System/Drupal.php)

I added a /var/www/demo/sites/all/modules/civicrm/settings_location.php, with the following...

Quote
<?php
define( 'CIVICRM_CONFDIR', '/var/www/demo/sites' );
?>

...but that didn't help.

PS. i would have run this same script via a URL but I get a 'Console_Getopt: Could not read cmd args (register_argc_argv=Off?)' error there (which has been reported elsewhere).
PPS. have checked at the username and password and key and this is being passed OK

Thanks, people
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Running bin/UpdateAddress.php from command line to geocode
June 03, 2011, 09:31:41 pm

easier to chat and debug this on IRC. Can u ping us on IRC next week :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Running bin/UpdateAddress.php from command line to geocode
June 30, 2011, 01:39:09 pm
Hi All,

I'm running into this problem as well.

It turns out that Debian Squeeze defaults to setting register_argc_argv to off in /etc/default/apach2/php.ini, which causes UpdateAddress.php to fail if you are using mod_php.

And - running directly via the command line fails if you have a multi-site installation because it can't determine the location of civicrm.settings.php.

It seems like both problems are fixable - via the web, the arguments could be parsed using $_SERVER['QUERY_STRING'].

Regariding the command line - maybe an extra argument could be passed to indicate which site to work on? Maybe something like this is already being considered?

jamie

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Running bin/UpdateAddress.php from command line to geocode
June 30, 2011, 03:54:36 pm
Normally that's what the -s is for, but UpdateAddress doesn't use cli.php (as bin/civimail.cronjob.php for instance). Not sure why.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Running bin/UpdateAddress.php from command line to geocode
July 01, 2011, 11:02:22 am
Thanks for pointing me in the right direction for the cli fix. Anyone else have ideas on why UpdateAddress.php doesn't use cli.php? If not I can take a stab and patching it.

jamie

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Running bin/UpdateAddress.php from command line to geocode
July 02, 2011, 08:48:49 am

no one has taken the effort to do it (legacy code etc). would be great if you can submit a patch to do so and convert it to a format similar to the other cron jobs

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Running bin/UpdateAddress.php from command line to geocode
July 13, 2011, 12:58:28 pm
I see why this script was left behind. This is not as simple a task as I thought.

cli.php expects --user|-u, --pass|-p, and --site|-s.

UpdateAddress.php allows you to pass: --name, --pass, --key (for authenticating) and --start, --end, --parse, --geocoding.

So - when using cli.php, we get errors saying "unrecognized options." I've started to patch cli.php so it's more abstracted - allowing you to create a cli object and specifiy the custom options. However, we're still left with the UpdateAddress.php wanting the username passed as --name and cli.php wanting it passed as --user. I'm inclined to change UpdateAddress.php to use the cli.php standard, but that will break existing scripts. Is that the right direction?

Also - cli.php seems to insist that CIVICRM_CONFDIR is defined, even if you've passed the site name. I"m not sure why that is and am working around it.

I'm tempted to scrap this work altogether and instead submit a patch to civicrm.drush.inc which could handle it all much more elegantly. But then, joomla users would be left out.

Thoughts?

jamie

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Running bin/UpdateAddress.php from command line to geocode
July 15, 2011, 11:18:16 pm
Can you submit an issue with the patch and assign it to me (for the cli abstraction)?

As for the conflict, I don't know how if some have it running in a crun. The easiest might be to copy it to a new bin/GeoEncode.php or whatever (I'm seldom using this bin, not sure what it does in details) and put the parameters you want.

We'll discuss with lobo and the core if it's a new bin and put an "obsoleted" warning in UpdateAddress or if we can safely enough replace UpdateAddress with it.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Running bin/UpdateAddress.php from command line to geocode
July 16, 2011, 12:24:21 am

I think it should be safe enough to fix it and do the right thing. Would be good to expand cli.php to allow additional parameters.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Running bin/UpdateAddress.php from command line to geocode
July 26, 2011, 03:27:55 pm
Done at last.

Abstracting cli.php: http://issues.civicrm.org/jira/browse/CRM-8565
Fixing UpdateAddress.php: http://issues.civicrm.org/jira/browse/CRM-8566

I'm not sure I did these changes in the best possible way - open to suggestions for improvements.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Running bin/UpdateAddress.php from command line to geocode

This forum was archived on 2017-11-26.