I am trying to run a program which requires a password inside TProcess. However, I cannot seem to pass this password from my Lazarus App to the process once it is running. Does anybody know how to go about it?
Thanx
Alex du Plessis

Mailing lists / lazarus / 2009-04
7 messages · 5 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
I am trying to run a program which requires a password inside TProcess. However, I cannot seem to pass this password from my Lazarus App to the process once it is running. Does anybody know how to go about it?
Thanx
Alex du Plessis
How do you execute the TProcess ?
How do you pass the password ?
Ido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090403/b6ef9a23/attachment-0001.html
i think when you execute the process you should prompt for password and check if it's legal.
i mean there's a dialog for the user to enter the password.
2009/4/3 ik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090403/9720afec/attachment.html
How do you execute the TProcess ? How do you pass the password ? Ido -------------- next…
I am trying to run pg_dump on a PostgreSQL database. On the command line one can specify the user name but not the password. Once the process is running pg_dump requests the password inside the console window. there is no commandline option to pass the password to the program.
I can get the process to run and once the password is entered in the console - the backup proceeds without a hitch. Please note: The password is only required once pg_dump is already running in the console. I even retrieve the output from the console (using the code as proposed in the Lazarus Wiki) into a TMemo and it works like a dream. I just cannot seem to communicate with pg_dump once the console is running.
I set the commandline to the appropriate command e.g. "%spg_dump.exe --host localhost --port 5432 --username postgres --format custom --blobs --oids --verbose --file "%s" mobman'
The %s i add when I know what the relevant directories and filenames are just before execution.
Then I do "Tprocess.Execute" with options poWaitOnExit=FALSE and poStdErrtoOutput=TRUE
No problem with that ...I just can't pass the password into the console once pg_dump is running except for typing it into the console via the keyboard.
As this will be an automated database backup, having to type the password is not an option as the client would not even know the password for the db server.
Can pgdump read from stdin?
If so, you might be able to use a pipe for stdin to supply the password? Just a thought, never actually tried something like that.
Bart
I am trying to run pg_dump on a PostgreSQL database. On the command line one can specify…
Alex du Plessis wroteI am trying to run pg_dump on a PostgreSQL database. On the command line one can specify the user name but not the password. Once the process is running pg_dump requests the password inside the console window. there is no commandline option to pass the password to the program.
A common way to do this is to enable IDENT authentication for PostgreSQL, so that a certain user (the backup user) is able to connect without a password, if connecting from localhost. That works quite well.
Maybe that's a possiblity?
Thanx - I'll try that