I'm writing a startup.sh script to be ran when a docker container is created.
#!/bin/bash
python manage.py runserver
python manage.py makemigrations accounts
python manage.py migrate
python manage.py check_permissions
python manage.py cities --import=country --force
*python manage.py shell | from cities.models import * Country.objects.all().exclude(name='United States").delete()*
python manage.py cities --import=cities
python manage.py cities --import=postal_code
I am guessing the line in question is incorrect, what would be the correct way to do this in a bash script?
foo | barconnects the stdout offooto the stdin ofbar. Thus, the command you proposed sends the output ofpython manage.py shellto the input of a command namedfrom, with its second argumentcities.models, &c.printf '%s\n' 'from cities.models import *' 'Country.objects.all().exclude(name="United States").delete()' | python manage.py shell-- that way you're sending the output of aprintfcommand that generates your script as the input to themanage.py shellcommand.