I am looking to export an array from my heroku console into a local CSV file.
In my current situation, I have a daily rake task which looks for tweets talking about my a
You can run Ruby on your Heroku instance:
echo 'p User.first' | heroku run --no-tty 'ruby -W0 -r ./config/environment' > output.txt
This will print the first user to the output.txt
file.
Also you can run a local script on Heroku by piping it to the stdin.
cat my_script.rb | heroku run --no-tty 'ruby -W0 -r ./config/environment' > output.txt
Note that it's possible that you'll get some unwanted text (like warnings) that will appear at the beginning of the output.txt
file. You will have to trim it manually or by using a trimming command such as:
tail -n +4 -f
that will not print the first 4 lines.
Here is the full example:
cat my_script.rb | heroku run --no-tty 'ruby -W0 -r ./config/environment' | tail -n +4 -f > output.txt