#!/usr/bin/expect -f
set type [lindex $argv 0]
set user [lindex $argv 1]
set host [lindex $argv 2]
set port [lindex $argv 3]
set password [lindex $argv 4]
set param [lindex $argv 5]
set timeout -1

switch $type {
    pwd {
        spawn ssh -o StrictHostKeyChecking=no -p$port $user@$host
        expect "*assword:*"
        send "$password\r"
}
    no_pwd {
        spawn ssh -o StrictHostKeyChecking=no -p$port $user@$host

    }
    key {
        spawn ssh -o StrictHostKeyChecking=no -i $param  -p$port $user@$host
    }
}

interact
#expect eof


