#!/usr/bin/expect -f # ssh.tcl # Fri Feb 13 20:14:07 PST 2009 # Chieh Cheng # http://www.CynosureX.com/ # GNU General Public License (GPL) Version 2, June 1991 if { $argc > 0 } { set str "ssh" set pw "" for { set i 0 } { $i < $argc } { incr i } { if { [string match "--password:*" [lindex $argv $i]] } { set pw [string range [lindex $argv $i] 11 99999] } else { set str "$str \"[lindex $argv $i]\"" } } eval spawn -noecho $str expect "*?assword:*" { send -- "$pw\r" } interact } else { spawn -noecho ssh expect eof spawn -noecho echo " \[--password:password\]" expect eof }