0

i wondering if there is any way to answer automatically a python script, this is the script (i run it with the next command "python manage.py syncdb")

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pydash.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

and when I execute it, this is the output:

Would you like to create one now? (yes/no): 
Username (leave blank to use 'root'): 
Email address: 
Password: 
Password (again): 

I know bash scripting but I am not good with python, so I am looking for an answer to this question automatically when I run the python script.

For information, this script comes from https://github.com/k3oni/pydash

1 Answer 1

1

Since you understand bash scripting, perhaps this bash command line would work for you.

{
    echo yes
    echo bobby-tables
    echo [email protected]
    echo "correct horse battery staple"
    echo "correct horse battery staple"
} | python manage.py syncdb
Sign up to request clarification or add additional context in comments.

6 Comments

thanks for the help, but i'm not sure that the command above is correct at all, or yes ?
What happens when you try it?
./script.sh: line 9: syntax error near unexpected token }' ./script.sh: line 9: } | python /var/www/pydash/manage.py syncdb'
Don't include the word "BASH$" in your script. I meant it only to indicate the shell prompt. I'll also delete it from my example.
ok, sorry my bad, it almost works, only i have a issue, it hang when python script ask for email address , the hang is here : You just installed Django's auth system, which means you don't have any superusers defined. Password: Would you like to create one now? (yes/no): Username (leave blank to use 'root'): Email address:
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.