0

I try to execute an PSQL from shell, and the thing is - it returns the error "command not found". I have a shell script in which there're lines:

ID3=`more DATA/Id3.txt`
psql -h localhost test test -Atc "SELECT id, reference, timestamp FROM restricted WHERE id='`$ID3`'" 

In the Id3.txt there's only the ID. When the psql command is written and executed direct through prompt - there's no problem at all and correct value is returned. When executed with a .sh file - error "command not found" is brought up. I have no clue why. Maybe anyone have a idea?

4
  • Do you get the same message if you run the psql -h ... command from your prompt? Commented Nov 25, 2013 at 14:17
  • Do you have the path to the binary in your PATH variable? Commented Nov 25, 2013 at 14:17
  • when running from prompt I get the ID from DB. It won't work only when run with a script Commented Nov 25, 2013 at 14:18
  • The error message is from the shell. The SQL command itself has nothing to do with it. The error kicks in an earlier stage. psql is not found. Commented Nov 29, 2013 at 17:30

2 Answers 2

1

In your script try to add which psql to see whether you can find the executable

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

Comments

1

Run below command on your console: whereis psql And then replace psql inyour script with the output of above command. This

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.