
razmot
New User
Jun 9, 2011, 6:21 AM
Post #1 of 5
(587 views)
|
|
System() call problem on Windows
|
Can't Post
|
|
I try to start a postgres backup job from a perl script. The script should create the backupfilenames and zip them. The command for that is pg_dump.exe. Looks like the parameters of the command are not correctly interpreted. When run from the windows commandline, the generated command-line works fine. When run from the perl script it asks for a password!!
my $tm = localtime(); my $backupfile = sprintf("%s/PostgresDBBackup_%s_%s_%04s%02s%02s%02s%02s%02s.bak", $BackupPath, $hostname, $DBName, $tm->year+1900, $tm->mon+1, $tm->mday, $tm->hour, $tm->min, $tm->sec); my $backupargs = sprintf("-f %s -F p --clean -U postgres -h localhost %s", $backupfile, $DBName); my @args = ($pgbackup, $backupargs); print "COMMAND: ".$pgbackup." ".$backupargs."\n"; my $status = system(@args); And this is the output: D:\Projects\Eclipse\workspace\DBBackups>perl PostgresBackup.pl //nas-tb/DBBackups misdwh E:\PostgreSQL\8.4SS\bin COMMAND: E:\PostgreSQL\8.4SS\bin/pg_dump.exe -f //nas-tb/DBBackups/PostgresDBBackup_TB-WS_misdwh_20110609151147.bak -F p --clean -U postgres -h localhost misdwh Passwort: pg_dump: [Archivierer (DB)] Verbindung zur Datenbank »TB« fehlgeschlagen: fe_sendauth: no password supplied 256 What I do not understand is the error message saying that the connection to the database "TB" failed. There is of course no database "TB". The name of the database is the last parameter passed and in my case 'misdwh'. By the way I tried the paths with backslashes and forwardslashes. Alsways the same error! Any idea what the problem could be?? Just for information: If the system is setup correctly, you NEVER have to pass a password on the command line to connect to the Server. The -U parameter specifies the user, the password is looked up in a file. As said if I copy the command I printed (the string after COMMAND) this works as a charm. Any idea what I am doing wrong in the perl script? Many thanks
|