473,765 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

postgres backup script and popen2

Hi,

i made a backup script to backup my postgres database.
Problem is that it prompts for a password. It thought i
could solve this by using popen2.
I tested popen2 with dir (i'm on windows 2000, python 2.4.3)
and it works.
However when i try popen2 and my pg_dump command, it prompts
for a password and I was under the impression that i was
going to be able to dynamically communicate with the process.

sin, sout = popen2(backup_c ommand)
sin.readline() # the password prompt
sout.write("pas sword")
sin.readlines()

How can i catch the password prompt and feed the password
from my code?

Thanks,
Benedict
Feb 8 '07 #1
5 2954
Use pexpect: http://pexpect.sourceforge.net/

flupke schrieb:
Hi,

i made a backup script to backup my postgres database.
Problem is that it prompts for a password. It thought i
could solve this by using popen2.
I tested popen2 with dir (i'm on windows 2000, python 2.4.3)
and it works.
However when i try popen2 and my pg_dump command, it prompts
for a password and I was under the impression that i was
going to be able to dynamically communicate with the process.

sin, sout = popen2(backup_c ommand)
sin.readline() # the password prompt
sout.write("pas sword")
sin.readlines()

How can i catch the password prompt and feed the password
from my code?

Thanks,
Benedict
Feb 8 '07 #2
On 8 feb, 10:27, Maël Benjamin Mettler <m...@mediamong er.chwrote:
flupke schrieb:
i made a backup script to backup my postgres database.
Problem is that it prompts for a password. It thought i
could solve this by using popen2.

Use pexpect:http://pexpect.sourceforge.net/
pexpect could work. But a better way would be to supply the password
on the command line. I don't know how postgres does that things, but I
hope there is some way to automate the backup process...

--
Gabriel Genellina

Feb 8 '07 #3
On 8 feb, 13:29, Jean-Paul Calderone <exar...@divmod .comwrote:
On 8 Feb 2007 08:23:49 -0800, Gabriel Genellina <gagsl...@yahoo .com.arwrote:
On 8 feb, 10:27, Maël Benjamin Mettler <m...@mediamong er.chwrote:
flupke schrieb:
i made a backup script to backup my postgres database.
Problem is that it prompts for a password. It thought i
could solve this by using popen2.
Use pexpect:http://pexpect.sourceforge.net/
pexpect could work. But a better way would be to supply the password
on the command line.

So that it shows up in `ps' output to anyone on the system? :)
Any solution has pros and cons... having the password in the source
code is not so good anyway...

--
Gabriel Genellina

Feb 8 '07 #4
In article <11************ *********@q2g20 00cwa.googlegro ups.com>,
"Gabriel Genellina" <ga******@yahoo .com.arwrote:
On 8 feb, 10:27, Maël Benjamin Mettler <m...@mediamong er.chwrote:
flupke schrieb:
i made a backup script to backup my postgres database.
Problem is that it prompts for a password. It thought i
could solve this by using popen2.
Use pexpect:http://pexpect.sourceforge.net/

pexpect could work. But a better way would be to supply the password
on the command line. I don't know how postgres does that things, but I
hope there is some way to automate the backup process...
See the Postgres documentation for the .pgpass file.

--
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Feb 8 '07 #5
flupke schreef:
<snip>

Thanks for all the info.
I'm sure i will get it right this time :)

Benedict
Feb 9 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

48
11925
by: Edwin Quijada | last post by:
Hi !! Everybody I am developing app using Delphi and I have a question: I have to save pictures into my database. Each picture has 20 o 30k aprox. What is the way more optimus? That 's table will have 500000 records around. Somebody said the best way to do that was encoder the picture to field bytea but I dont know about this. Another way is save the path to the picture file but I dont like so much because I need to write to disk by OS...
3
4207
by: N.K. | last post by:
Hi, I've just installed postgres on the Linux server. It is supposed to start automatically which I think it does since I can run an sql stmt right away. When I'm trying to connect from a remote machine I get a message that the remote machine IP address is not specified in pg_hba.conf, that there is no record of that machine there. ph_hba.conf is set up correctly, because when I run the following: postmaster -i -D /var/lib/pgsql/data...
7
6665
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had the whole db changed over in 1 hour. Since the upgrade I have been getting the following error message sporadically.
5
14249
by: Fabio Benavides Murillo | last post by:
> Hello > > I have a problem, I want to migrate the data of a postgres' database to a > mysql's database, this because i need to move to a windows. > > I tried making a postgres' backup using pg_dump, but this file doesn't have > the insert in Transac-sql. > > Any help is welcome
18
2026
by: Chris Travers | last post by:
Hi all; I have been looking into how to ensure that synchronous replication, etc. could best be implimented. To date, I see only two options: incorporate the replication code into the database backend or have a separate "proxy" which handles the replication. The main problem with incorporating the system into the backend process is that it limits the development to the 10-month timeframe between releases. The main advantage is that...
1
6283
by: Matthew Hixson | last post by:
I am currently working on a Java web application in which we are making use of the JDBC driver for Postgres 7.4.1. Part of our application allows the administrators to manage a large number of small images, most of them not exceeding 5KB. There is about a gigabyte of these small files. We're currently storing the files on disk and the other information about the file in the database (historical reasons that I won't complain about here)....
2
1243
by: Holger | last post by:
I needed a tool for extracting patches from CVS based on the log messages. I.e. we mark our fixes and features with a "Bugdb XYZ" And sometimes you need to move a fix/feature to another branch or maybe you just want to inspect exactly what changes were related to a specific bugdb issue. Now I've searched hi and low for this and I now it's out there somewhere bleeding obvious - can't imagine I'm the first to have this thought. I just...
2
2850
by: Gerard Flanagan | last post by:
Hello, I have a third party shell script which updates multiple environment values, and I want to investigate (and ultimately capture to python) the environment state after the script has run. But running the script as a child process only sets values for that process, which are lost after execution. So I thought I could simply tack on an 'env' command line to the script input lines as shown below. However, using subprocess.Popen gives...
1
4383
by: micofarmer | last post by:
We are running a PHP web-based frontend with a Postgres 7.2 backend on a Windows 2000 Server box with automated backups of the server being handled by Legato. We are experiencing several problems that point in the general direction of the backup process but we have nothing concrete. The Legato system runs incremental backups Monday through Saturday with a full server backup on Sunday. The problems we are seeing are mainly database...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.