0

I am writing a batch job for Postgres for first time. I have return ".sh" file, which has a command with out any out put in the log or console.

Code

export PGPASSWORD=<password>
psql -h <host> -p <port> -U <user> -d <database> --file cleardata.sql > log\cleardata.log 2>&1

What I did at cammond line

su postgres

and run ./cleardatasetup.sh

Nothing is happening.

Please note : When I try psql command in Unix command line, I am getting message as some SQL exception which is valid.

Can any one please help me in this regard.

1 Answer 1

1

You probably wanted to create log/cleardata.log but you have a backslash where you need a slash. You will find that the result is a file named log\cleardata.log instead.

The backslash is just a regular character in the file's name, but it's special to the shell, so you'll need to quote or escape it to (unambiguously) manipulate it from the shell;

ls -l log\\cleardata.log  # escaped
mv 'log\cleardata.log' log/cleardata.log  # quoted
Sign up to request clarification or add additional context in comments.

Comments

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.