开发者

input from file in batch file problem

i need to enter password two time for this command when it ask

createuser -h localhost -P -p 5432 -s -d -r -e postgres 

i tried

createuser -h localhost -P -p 5432 -s -d -r -e postgres &开发者_Python百科lt; temp.txt

where temp.txt contains

password

password

it still asks for password

any suggestions?


The createuser program probably makes its own connection to the terminal rather than reading from its standard input, this is common behavior where passwords are concerned. You'll probably have better luck using the SQL CREATE ROLE rather than createuser:

echo "CREATE ROLE postgres CREATEROLE CREATEDB SUPERUSER PASSWORD 'password';" \   
    | psql -h localhost -p 5432 databasename

Where "databasename" is the name of your database.

From the fine manual:

createuser is a wrapper around the SQL command CREATE ROLE. There is no effective difference between creating users via this utility and via other methods for accessing the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜