I have written a shell script to execute postgresql commands . Problem is when I am executing this script it is showing an error : line 17: psql: command not found
my script is as follows:
export PGPASSWORD=${PGPASSWORD-my_password}
echo "enter host"
read host
echo "enter database name"
read dbname
echo "enter username"
read username
psql -h $host $dbname $username <<EOF
SELECT * FROM test ; >>res.txt
EOF
( cat res.txt) | sed 's/;/<tab>/g' > $file.csv
rm res.txt
unset PGPASSWORD
Please suggest me what I am doing wrong .
line 17: psql: command not found
? You need to either specify the complete path topsql
or install it if it doesn't exist. – devnull 11 hours agowhereis psql
? – Antarus 11 hours agoPATH
as well. Try issuingpsql
from the command line; you'll figure. – devnull 11 hours ago