I was planning to use drush views-data-export to write some data to a specific path on my host. To problem is that the output path for the generated file is always relative to the path where drush views-data-export is called.

Example: drush views-data-export myviewname views_data_export_1 output.csv

If I am currently working in the folder sites/all/themes then the output file will be generated at sites/all/themes/output.csv.

I have tried to add an absolute path to the drush command, but this:
drush views-data-export myviewname views_data_export_1 /var/www/vhost/test/drupal/sites/default/files/output.csv will produce an error

file_put_contents(/var/www/vhost/test/drupal/sites/all/themes//var/www/vhost/test/drupal/sites/all/themes/output.csv):[warning]
failed to open stream: No such file or directory views_data_export.drush.inc:183
The file could not be copied to the selected destination                                             [error]

I guess this is a bug.

Possible solution: views_data_export.drush should check if the argument for the file name starts with a slash. If that is the case then the current path should not be prepended in file_put_contents(). That way you can use both relative and absolute paths as output arguments.

CommentFileSizeAuthor
#2 can_not_use_absolute-2284975-2.patch1014 bytesSteven Jones
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BillyTom’s picture

Issue summary: View changes
Steven Jones’s picture

Status: Active » Needs review
FileSize
1014 bytes

How about this.

  • Steven Jones committed 32abc1a on 7.x-3.x
    Issue #2284975 by Steven Jones: Fixed Can not use absolute output path...
Steven Jones’s picture

Status: Needs review » Fixed

Committed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

BillyTom’s picture

Thank you very much.