English 中文(简体)
利用ash子自动解答用于石墨安装的 d灯
原标题:using bash to automate answering of prompts for django sync for graphite install

我正在用che子将布汶tu的布局成行。 我需要使这名新来者能够管理。 采用ash或采用其他方式的 p。

ubuntu@ip-xxx-xxx-xxx:/opt/graphite/webapp/graphite$ sudo python manage.py syncdb
Creating tables ...
Creating table account_profile
Creating table account_variable
Creating table account_view
Creating table account_window
Creating table account_mygraph
Creating table dashboard_dashboard_owners
Creating table dashboard_dashboard
Creating table events_event
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_session
Creating table django_admin_log
Creating table django_content_type
Creating table tagging_tag
Creating table tagging_taggeditem

You just installed Django s auth system, which means you don t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use  root ): admin
E-mail address: [email protected]
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
No fixtures found.

我需要使下列事件自动化:

Would you like to create one now? (yes/no): yes
Username (Leave blank to use  root ): admin
E-mail address: [email protected]
Password: test101
Password (again): test101

成就

最佳回答

您可尝试Expect。 我从未使用过除偷窃以外的任何东西,但应该以任何互动方式开展工作。

问题回答

页: 1 我也存在同样的问题,并用我所期望的数字解决了这个问题。

set timeout -1
set program [ lindex $argv 0 ]
eval spawn $program [ lrange $argv 1 end ]
expect {
    "Would you like to create one now" {
            send "yes
"
            expect "Username"
            send "admin
"
            expect "E-mail"
            send "[email protected]
"
            expect "Password"
            send "admin
"
            expect "Password"
            send "admin
"
            exp_continue
     } "Migrated" {
            expect eof
     }
}

重任定制缺省的行政和密码。

如果你需要解决“投入”问题,并希望利用结构使行政创建自动化,则考虑通过<代码>-无投入<>代码>,在syncdb上挂有用户数据显示的固定<>/strong>。

参看

仅仅把数据推到工作阶段吗?

printf "%s
" yes admin [email protected] test101 test101 | sudo python ...

sudo sh -c  printf "%s
" yes admin [email protected] test101 test101 | python ... 

我刚刚发现这一点,但我要说的是no,而不是yes。 因此,根据单科蒂的榜样,这里是一种最低预期文字。

set timeout -1                                                                                                                                                          
spawn "./your_django_script.sh"                                                                                                                                     
expect {                                                                                                                                                                
    "Would you like to create one now" {                                                                                                                                
            send "no
"                                                                                                                                                 
            exp_continue                                                                                                                                                
     }                                                                                                                                                                  
}   




相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...