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