I have script:
#!/bin/sh
PSQLPATH=$1
USER=$2
if [ -z ${PSQLPATH} ]; then
echo "incorrect path param"
echo "Usage: $0 psqlpath username"
exit 1
fi
if [ -z ${USER} ]; then
echo "incorrect username param"
echo "Usage: $0 psqlpath username"
exit 1
fi
${PSQLPATH}/createdb -h localhost -U ${USER} highway2
${PSQLPATH}/psql -f createDatatable.sql -h localhost -d highway2 -U ${USER}
${PSQLPATH}/psql -f insertStatements.sql -h localhost -d highway2 -U ${USER}
echo "execute passed"
exit 0
When I am trying to execute it like ./script.sh I got an error line 19: unexpected end of file. What I am doing wrong?
Check your line endings. When I run your script (under Cygwin), with no arguments given, I get your error if I have Windows-style line endings (
\r\n). When I use Unix-style line endings, by eliminating the\rs, the script runs, complaining about my not having given the correct parameters.