以编程方式输入osm2pgsql密码

时间:2014-04-25 16:58:01

标签: python subprocess ipc pipe

假设我有

osm2pgsql_proc = sp.Popen(
     [osm2pgsql, "--create", "--database", db_name, 
        "--cache", str(cache_size), "--number-processes", 
        str(osm2pgsql_number_processes), "--slim", "--port", str(db_port), 
        "--host", db_host, "--username", db_user, "--latlong", "--password", 
        "--keep-coastlines", "--extra-attributes", "--hstore-all"]+osm_files, 
    stdin=sp.PIPE)
# tried all of the following alternatives
#osm2pgsql_proc.stdin.write(db_password+"\x1a")
#osm2pgsql_proc.stdin.flush()
#osm2pgsql_proc.stdin.write(db_password+"\n")
#osm2pgsql_proc.stdin.flush()
#osm2pgsql_proc.communicate(db_password+"\x1a")
#osm2pgsql_proc.communicate(db_password+"\n")
#osm2pgsql_proc.stdin.flush()
osm2pgsql_proc.wait()

如何通过Password:提示?

请注意:我知道pexpect我可以想象可能有类似的模块,但我正在寻找一个解决方案,它也可以更好地理解python和OS,Linux的子进程和相关概念,除了有人可以提供一个似是而非的答案,解释说它不能按照我理解的方式工作。

0 个答案:

没有答案
相关问题