1、用shell脚本实现自动登录机器
#!/usr/bin/expect
#!/usr/bin/expect
set ip [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set timeout 15
spawn ssh $user@$ip
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n" }
}
interact
#!/bin/bash 可以登录 但是登录后自动退出
#!/bin/bash
ip=$1
user=$2
password=$3
expect <<EOF
set timeout 15
spawn ssh $user@$ip
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n" }
}
expect eof
EOF
2、shell 判断一个值bone是否在数组arrayZ=( one two three four five five )中
#!/bin/bash
declare -a arrayZ
arrayZ=( one two three four five )
bone="bone"

本文涵盖了使用Shell脚本实现Linux自动登录机器的方法,探讨了如何在数组中判断值是否存在,以及将MAC地址转换格式的命令和脚本。此外,文章还详细介绍了CentOS7的开机流程,并指导编写Nginx的systemd配置以实现开机启动。
最低0.47元/天 解锁文章
738

被折叠的 条评论
为什么被折叠?



