import.sh 392 B

123456789101112131415
  1. #!/bin/expect
  2. set timeout 300
  3. set host [lindex $argv 0]
  4. set port [lindex $argv 1]
  5. set username [lindex $argv 2]
  6. set password [lindex $argv 3]
  7. set dbname [lindex $argv 4]
  8. set table [lindex $argv 5]
  9. set filename [lindex $argv 6]
  10. spawn psql -h ${host} -p ${port} -U ${username} -d ${dbname} -c "\\copy ${table} from ${filename} with csv"
  11. expect "Password" {
  12. send "${password}\r"
  13. }
  14. expect eof