Question

Originally I thought this was a db administration issue, but I think the lines have become a little blurred. I'm going to keep this strictly a scripting problem here. If you want more background info I posted this on ServerFault here:

https://serverfault.com/questions/511780/postgresql-pgdump-script-on-rhel5-failed-fe-sendauth-no-password-supplieddat

My Script

I distilled my original script down to this to keep things simple. This is what I have in a .sh named pg_dump_script:

/home/myusername/lappstack-1.2-5/postgresql/bin/pg_dump --host=127.0.0.1 --port=5433 --username=myusername mydbname

When I run this I get the following error:

$ bash pg_dump_script.sh
Password:
" does not exist  database "corenection to database "mydbname

I can copy and paste the line in the script file and run it from the command line and everything works fine.

Here are the permission on the script file:

-rwxr-xr-x

I used chmod 755

I'm not sure what I'm doing wrong here? I'm not an expert on scripting, but I thought if I could run it from the console it would of course run fine from a script. Let me know if any information is needed. I'm trying to keep this simple.

Updates

I removed all parameters. This is all the text in the .sh

/home/myusername/lappstack-1.2-5/postgresql/bin/pg_dump

I receive this error:

    $ ./pg_dump_script.sh
: No such file or directoryine 1: /home/myusername/lappstack-1.2-5/postgresql/bin/pg_dump
: command not foundst.sh: line 2:
Was it helpful?

Solution

Run dos2unix on your .sh file to convert to proper UN*X line endings and it should work:

dos2unix pg_dump_script.sh

When editing with vi check to make sure it's not in dos edit mode. If you start with an original text file with CR/LF in it, vi will automatically go into dos mode unless you tell it otherwise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top