expect 运行脚本文件 执行postgres数据库操作

#!/bin/bash
/usr/bin/expect  << EOF
spawn /usr/local/pgsql/bin/2.sh
expect "*postgres:"
send "postgres
"
set timeout 7200
expect eof
EOF

2.sh

#!/bin/bash /usr/local/pgsql/bin/psql -h 192.168.16.26 -p 5432 -U postgres -W -c "select delete_collection_data()" bigdata
原文地址:https://www.cnblogs.com/kcxg/p/11571917.html