1

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:
12
  • Is that the actual error message? I'm not sure what a "corenection" is. Commented May 31, 2013 at 12:55
  • Yes, that's the actual error message copy and pasted. I know it seems weird. I really want to upload a print screen, because when I first saw it I thought my eyes were playing tricks on me. Commented May 31, 2013 at 12:55
  • 3
    Your script contains DOS line endings; note how the carriage return is causing the error messages to seemingly overlap. Commented May 31, 2013 at 13:30
  • 1
    Ah good thought chepner, @enigmasck, try running dos2unix on your script file (make a backup copy of the script first). Commented May 31, 2013 at 13:41
  • 1
    holy crapppp.... dos2unix worked...Both of you deserve credit for this! Please provide an answer so I can upvote! Commented May 31, 2013 at 13:47

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Another way is to use Notepad++. From the menu select Edit →EOL Conversion → Unix

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.