Batch: DB password with ">"

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Batch: DB password with ">"

Schenk, Hendrik

Hi,

 

i want to modiy the adatabse via batch script. The user has a password that contains symbols like that “g>uAks!”. The problem here is the “greater than”-symbol.

 

call set PGPASSFILE=%TEMP%\pgpass.conf

echo localhost:5432:postgres:postgres:7Ug^>uAks!{VA > %PGPASSFILE%

 

"C:\Program Files\PostgreSQL\10\bin\psql" -U postgres

 

psql will always fail with FATAL: User-Athentification failed. The password was read from ..\Local\Temp\pgpass.conf

 

 

 

 

If I set a Enviromentvariable and “echo” it, it will not work, because of the >-symbol.

 

 

C:\Users\hschenk>set PGPASSWORD=lalal>lala

 

C:\Users\hschenk>echo %PGPASSWORD%

Lalal

 

How can I use this with a password like this?

Reply | Threaded
Open this post in threaded view
|

Re: Batch: DB password with ">"

David G Johnston
On Thursday, October 11, 2018, Schenk, Hendrik <[hidden email]> wrote: 

How can I use this with a password like this?


Maybe use single quotes to prevent the shell from seeing its special symbol?

David J. 
Reply | Threaded
Open this post in threaded view
|

Re: Batch: DB password with ">"

Jay at Verizon
And you may need to escape it with a preceding \ character.
Jay

Sent from my iPhone

On Oct 11, 2018, at 9:45 AM, David G. Johnston <[hidden email]> wrote:

On Thursday, October 11, 2018, Schenk, Hendrik <[hidden email]> wrote: 

How can I use this with a password like this?


Maybe use single quotes to prevent the shell from seeing its special symbol?

David J. 
Reply | Threaded
Open this post in threaded view
|

Re: Batch: DB password with ">"

Shreeyansh dba
In reply to this post by Schenk, Hendrik
Hi,

You can use below command to get the desired output.

echo localhost:5432:postgres:postgres:7Ug^\>uAks!{VA > %PGPASSFILE%
                                                 or
echo "localhost:5432:postgres:postgres:7Ug^>uAks!{VA" > %PGPASSFILE% 




On Thu, Oct 11, 2018 at 6:38 PM Schenk, Hendrik <[hidden email]> wrote:

Hi,

 

i want to modiy the adatabse via batch script. The user has a password that contains symbols like that “g>uAks!”. The problem here is the “greater than”-symbol.

 

call set PGPASSFILE=%TEMP%\pgpass.conf

echo localhost:5432:postgres:postgres:7Ug^>uAks!{VA > %PGPASSFILE%

 

"C:\Program Files\PostgreSQL\10\bin\psql" -U postgres

 

psql will always fail with FATAL: User-Athentification failed. The password was read from ..\Local\Temp\pgpass.conf

 

 

 

 

If I set a Enviromentvariable and “echo” it, it will not work, because of the >-symbol.

 

 

C:\Users\hschenk>set PGPASSWORD=lalal>lala

 

C:\Users\hschenk>echo %PGPASSWORD%

Lalal

 

How can I use this with a password like this?

Reply | Threaded
Open this post in threaded view
|

AW: Batch: DB password with ">"

Schenk, Hendrik

Hi,

 

single quotes, double quotes, escaping with

\ or

^ or

^\  or

\^

 

does not work.

 

echo localhost:5432:postgres:postgres:7Ug^\>uAks!{VA > %PGPASSFILE% does not escape the “>”-symbol.

echo "localhost:5432:postgres:postgres:7Ug^>uAks!{VA" > %PGPASSFILE% does not work, because psql seems not to understand the pgconf-file, does not check the file for a password and give me a pw prompt.

 

 

Best regards

Hendrik

 

Von: Shreeyansh Dba <[hidden email]>
Gesendet: Donnerstag, 11. Oktober 2018 17:17
An: Schenk, Hendrik <[hidden email]>
Cc: [hidden email]
Betreff: Re: Batch: DB password with ">"

 

Hi,

You can use below command to get the desired output.

echo localhost:5432:postgres:postgres:7Ug^\>uAks!{VA > %PGPASSFILE%
                                                 or

echo "localhost:5432:postgres:postgres:7Ug^>uAks!{VA" > %PGPASSFILE% 

 

Das Bild wurde vom Absender entfernt.

 

 

On Thu, Oct 11, 2018 at 6:38 PM Schenk, Hendrik <[hidden email]> wrote:

Hi,

 

i want to modiy the adatabse via batch script. The user has a password that contains symbols like that “g>uAks!”. The problem here is the “greater than”-symbol.

 

call set PGPASSFILE=%TEMP%\pgpass.conf

echo localhost:5432:postgres:postgres:7Ug^>uAks!{VA > %PGPASSFILE%

 

"C:\Program Files\PostgreSQL\10\bin\psql" -U postgres

 

psql will always fail with FATAL: User-Athentification failed. The password was read from ..\Local\Temp\pgpass.conf

 

 

 

 

If I set a Enviromentvariable and “echo” it, it will not work, because of the >-symbol.

 

 

C:\Users\hschenk>set PGPASSWORD=lalal>lala

 

C:\Users\hschenk>echo %PGPASSWORD%

Lalal

 

How can I use this with a password like this?

Reply | Threaded
Open this post in threaded view
|

AW: Batch: DB password with ">"

Schenk, Hendrik
In reply to this post by Shreeyansh dba

There was a space too much between the password and the streaming operator. So the password was extended by a trailing space.

Furthermore you have to escape the >-symbol first with the carret in the windows command shell and then the escape-symbol \ for psql.

 

 

echo localhost:5432:postgres:postgres: 7Ug\^>uAks!{VA> %PGPASSFILE%

 

 

best regards

Hendrik

 

Von: Shreeyansh Dba <[hidden email]>
Gesendet: Donnerstag, 11. Oktober 2018 17:17
An: Schenk, Hendrik <[hidden email]>
Cc: [hidden email]
Betreff: Re: Batch: DB password with ">"

 

Hi,

You can use below command to get the desired output.

echo localhost:5432:postgres:postgres:7Ug^\>uAks!{VA > %PGPASSFILE%
                                                 or

echo "localhost:5432:postgres:postgres:7Ug^>uAks!{VA" > %PGPASSFILE% 

 

Das Bild wurde vom Absender entfernt.

 

 

On Thu, Oct 11, 2018 at 6:38 PM Schenk, Hendrik <[hidden email]> wrote:

Hi,

 

i want to modiy the adatabse via batch script. The user has a password that contains symbols like that “g>uAks!”. The problem here is the “greater than”-symbol.

 

call set PGPASSFILE=%TEMP%\pgpass.conf

echo localhost:5432:postgres:postgres:7Ug^>uAks!{VA > %PGPASSFILE%

 

"C:\Program Files\PostgreSQL\10\bin\psql" -U postgres

 

psql will always fail with FATAL: User-Athentification failed. The password was read from ..\Local\Temp\pgpass.conf

 

 

 

 

If I set a Enviromentvariable and “echo” it, it will not work, because of the >-symbol.

 

 

C:\Users\hschenk>set PGPASSWORD=lalal>lala

 

C:\Users\hschenk>echo %PGPASSWORD%

Lalal

 

How can I use this with a password like this?