expect -c 'spawn ssh root@3wa.tw ; expect assword ; send "1234567\n" ; expect 3wa;send "logout\n" ; interact' ssh 自動登入的小技巧 #!/usr/bin/expect spawn ssh www.president.gov.tw expect "*Yes*" send "yes\n" expect "*password:*" send "MaInNine\n" expect "localhost" send "ls\n" expect eof # aaa.exp #!/usr/bin/expect spawn ssh [lindex $argv 0] expect "password:" send [lindex $argv 1] send "\n" expect "localhost" send [lindex $argv 2] send "\n" expect eof