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

steven jones’s picture

Status: Active » Closed (won't fix)

Sorry for the lack of attention to your issue, please accept my apologies.

Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.

As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.

If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.

Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)