osm2pgsql

When using osm2pgsql in a script to regularly update my osm database i’m always asked for the password. Is it possible to omit this so i can rund the script by a nightly cron job? Or maybe can i pass the password to osm2pgsql in the script?

Best regards
Sven

A workaround is to config PostGIS so that it does not require password. Try setting authentication method to “trust” for local users in pg_hba.conf.

I already tried this but it didn’t work on my machine.
Found a better way now, just changed the source code :wink:

Thanks

Could you change the source to get the password from a config file, and send in a patch?

I would do this, but i’m not that firm in programming with C. :roll_eyes:
I’m just happy that i found the source to change for disabling the password prompt. So this works for me on my local machine.

I changed the following in osm2pgsql.c: (it’s about on line 540)

//if (username || pass_prompt)
//    password = simple_prompt("Password:", 100, 0);

//conninfo = build_conninfo(db, username, password, host, port);
conninfo = build_conninfo(db, username, NULL, host, port);

Commented out the if statement and changed the call to build_conninfo, set password to the fixed value “NULL”.

It would be nice to have osm2pgsql for Windows maintained somehow. It is now 6 months old and lacks a few nice new features, for example reading list of tags to be imported from a file etc. But perhaps I am the only Windows handicapped user here. In addition, Windows specific source code was never put to OSM trac so it is hard to maintain even somebody gets interested.

You could try to run that program under linux instead. Download cooperative Linux, which allows you to run Linux under Windows XP (perhaps vista) without emulation. It worked fine for me in ~2004 so I think it should be even better now.