编写一个登录postgreSQL的shell脚本
时间: 2024-05-21 21:11:21 浏览: 113
postgresql脚本
#!/bin/bash
echo "Enter the PostgreSQL username: "
read username
echo "Enter the PostgreSQL password: "
read -s password
echo "Enter the PostgreSQL database name: "
read database
# Log into PostgreSQL using the provided credentials
psql -U $username -d $database -c "SELECT version();"
# Check if the login was successful
if [ $? -eq 0 ]
then
echo "Login successful"
else
echo "Login failed"
fi
# End of script
阅读全文