#! /usr/bin/expect -f
# this script is used to practise the command "expect"

#when "lindex" have been used here, the array index begins with 0 but not with 1
set user [lindex $argv 0]
set host [lindex $argv 1]
set passwd [lindex $argv 2]
set timeout 10

spawn ssh $user@$host
# expect "[yes/no]" {send "yes\r"}  if 'ssh-ing' a server for the first time,

# you most likely encounter the case above concerning RSA
expect "password:" {send "$passwd\r"}
interact

 

# modify the script mode to be 0744

# now, one runs "./login.exp your_name host_name your_passwd" in the bash shell, logging in the server successfully.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-08-07
  • 2021-12-05
  • 2021-11-07
  • 2022-02-20
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案