I'd like to add a line in my crontab to export the result of a view using this module but I'm experiencing some problems:

Here the line I'm using (in the shell):
drush -d -r /home/user1/public_html views-data-export numbers_report views_data_export_1 /home/user1/public_html/report.xls

This line end without creating the report.xls file and with a "The file could not be copied to the selected destination" error.

With the -d (debug option) I isolated the line below:

Undefined variable: header views_data_export.theme.inc:300 [13.01 sec, 69.16 MB]                 [notice]
Undefined offset:  0 tablesort.inc:168 [13.01 sec, 69.16 MB]                                     [notice]
Undefined offset:  0 tablesort.inc:173 [13.01 sec, 69.16 MB]                                     [notice]
Undefined variable: output views_data_export.theme.inc:308 [13.01 sec, 69.16 MB]                 [notice]
The file could not be copied to the selected destination [13.01 sec, 69.16 MB]                [error]
Command dispatch complete [13.01 sec, 69.16 MB]                                                  [notice]
Peak memory usage was 76.38 MB [13.01 sec, 69.16 MB]                                             [memory]
Undefined offset:  0 tablesort.inc:168 [13.12 sec, 72.86 MB]                                     [notice]

What's wrong in my line? Can anyone please help me? I see several people could export data via cron but couldn't find an example of the line in the cron.

(I also changed the permissions on that View, so that everybody can download the report)

Comments

Balbo’s picture

bump?

brephraim’s picture

Version: 6.x-2.0-beta5 » 7.x-3.0-beta6

Same problem here...

Steven Jones’s picture

It would seem that Drush is having issues creating a file at the location you specified, does the user running Drush have permissions to write to that location?

You could try running:

touch /home/user1/public_html/report.xls

With the same user and see if that call succeeds.

johnv’s picture

I have a different, two-line approach, going to the desired location before starting drush:

cd /home/domains/../temp
drush views-data-export my_view my_display my_file.csv 
Steven Jones’s picture

Status: Active » Closed (cannot reproduce)

Closing after no response.

pnigro’s picture

Status: Closed (cannot reproduce) » Active

Hello,

I was experiencing the same problem. Below is the debug output by drush.

Calling copy(temporary://views_data_exportRYXAi2_0, /var/www/html/production//var/www/html/production/feeds/feed.txt)
The file could not be copied to the selected destination

It looks like the export has to be saved in the drupal enviroment where "drush views-data-export" was executed in order for it to work. In my case the file would have to be saved in "/var/www/html/production/". Otherwise you end up with an invalid path "/var/www/html/production//var/www/html/production/feeds/feed.txt" which results in the error.

Therefore, the output file in "drush views-data-export [view-name] [display-id] [output-file]" cannot include an absolute path. For example:

drush views-data-export export_view views_data_export_1 feeds/feed.txt [success]
drush views-data-export export_view views_data_export_1 /var/www/html/feeds/feed.txt [error]

I believe this is caused by:

  $options = array (
    'output_file' => realpath(drush_get_context('DRUSH_OLDCWD', getcwd())) . '/' . $output_file,
  );

in views_data_export.drush.inc.

I hope this helps others that have encountered this issue.

Thanks
Paul