#!/usr/bin/expect
if { $argc != 3 } {
        send_user "Usage: USER,PASSWD,CMD:\n"
        exit
}


set timeout 10

set User [lindex $argv 0]
set Passwd [lindex $argv 1]
set Cmd [lindex $argv 2]

set version [exec sh -c {grep "ProductVersion" /opt/huawei/deploy/package/version | awk -F '[=]' '{print $2}'}]
if {$version >= "V500R007C10SPC500"} {
 spawn /startup_disk/image/ISM/ism_ap/CLI/ismcli/start.sh  -u $User -force "$Cmd"
} else {
spawn /startup_disk/image/ISM/ism_ap/CLI/ismcli/start.sh  -u $User "$Cmd"
}

expect "Please input password:"
send "$Passwd\r"

expect eof
exit 0
