1.  
     
  2.  
    #!/usr/bin/expect
  3.  
     
  4.  
     
  5.  
    set host [lrange $argv 0 0]
  6.  
    set port [lrange $argv 1 1]
  7.  
    set db [lrange $argv 2 2]

执行expect脚本的命令为:

expect create_database.sh node1 5432 zz1