92

I'm using a Github post-recieve hook to run a bash file that pulls both my repos.

#!/bin/sh
cd ~/public_html/repo_static
env -i /usr/bin/git pull origin master
cd ~/django-code/repo_django
env -i /usr/bin/git pull origin master

I also want to collectstatic on the django repo. How do I automate the "yes" response to that?

I can't use Fabric because unfortunately the team chose to work with Python 2.4 for the time being. Is there a way to automate collectstatic without Fabric?

Artur Sapek
  • 2,425
  • 6
  • 27
  • 29
  • People landing on this question may also be interested in [this question](https://stackoverflow.com/questions/38862567/gcloud-app-deploy-flag-to-automate-prompting) about non-interactive gcloud deployments. – pdoherty926 Mar 26 '19 at 15:38

2 Answers2

243
python manage.py collectstatic --noinput
Tommaso Barbugli
  • 11,781
  • 2
  • 42
  • 41
16

If you'd like to specify the default answer, you could also just pipe it into the command:

$ echo yes | python manage.py collectstatic

or

$ echo no | python manage.py collectstatic
Kris
  • 22,079
  • 3
  • 30
  • 35
  • @Paullo It may be an issue with permissions or the shebang in `manage.py`. I edited the command to be called by `python` executable explicitly. – Kris Sep 11 '20 at 00:58