自动连接的脚本

来源:互联网 发布:python递归函数怎么写 编辑:程序博客网 时间:2024/06/04 17:51
  1 #!/bin/bash
  2 read -p 'user:'  USER
  3 read -p 'ipaddr:'  IP
  4 ssh $USER@$IP

  1 #!/usr/bin/expect
  2 set USER [ lindex $argv 0 ]
  3 set IP [ lindex $argv 1 ]
  4 set PASSWD [ lindex $argv 2 ]
  5 spawn /mnt/ssh.sh
  6 expect {
  7         "Are you sure" { send "yes\r"; exp_continue }
  8         "user" { send "$USER\r"; exp_continue }
  9         "ipaddr" { send "$IP\r"; exp_continue }
 10         "password" { send "$PASSWD\r"; exp_continue }
 11 expect eof
 12 }
 13 interact
~               
0 0
原创粉丝点击