Assume I have
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()
How do I get past the Password: prompt?
Please notice: I know about pexpect and I can image there might be similar modules, but I'm looking for a solution which also offers a better understanding of subprocess and related concepts of python and OS, Linux respectively, except someone can provide a plausible answer explaining that it doesn't work the way I understand it should to work.
osm2pgsqlsupports openssl-like-passinparameter that allows to specify the source for the password (a file, pipe, command-line, envvar, etc)pexpectcode specific to your case.ptymodule directly (you canos.writetomaster_fd).