小编min*_*rix的帖子

用于SSH的Bash/Expect脚本

我是新手,期待和编写脚本.我正在尝试制作一些脚本,以便在拉动网络设备配置时让我的生活更轻松一些.我设法创建一个基本的期望脚本来SSH到设备并保存配置.

我想扩展这个并允许脚本连接到许多IP地址,而不是像我现在一样.我有一个名为list.txt几个不同IP地址的文件,每个IP在一个单独的行上.

我需要做什么才能让expect脚本连接到每个IP地址并执行脚本中的其余任务?

这是我到目前为止的Expect脚本:

#!/usr/bin/expect -f
#Tells interpreter where the expect program is located.  This may need adjusting according to
#your specific environment.  Type ' which expect ' (without quotes) at a command prompt
#to find where it is located on your system and adjust the following line accordingly.
#
#
#Use the built in telnet program to connect to an IP and port number
spawn ssh 192.168.1.4 -l admin
#
#The first thing we should see is …
Run Code Online (Sandbox Code Playgroud)

ssh bash expect

7
推荐指数
1
解决办法
6万
查看次数

标签 统计

bash ×1

expect ×1

ssh ×1