#!/usr/bin/expectset timeout 30set user USERNAMEset pass PASSWORDspawn sudo pg_dump npi -U admin -p PORT -h IP -f /home/pgsql_bak/expect { "Password" {send "$pass\r"}}expect eof