Linux工作笔记-解决spawn: not found与expect: not found问题(安装expect)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq78442761/article/details/84062445

首先要下载安装2个程序:

1.tcl:下载链接如下:

8.4.11版本:https://download.csdn.net/download/qq78442761/10783733

8.4.19版本(新版本的Linux要安装新版本的):https://download.csdn.net/download/qq78442761/10783743

2.expect:下载链接如下:

5.4版本:https://download.csdn.net/download/qq78442761/10783720

首先安装tcl,

在tcl文件里面有个unix文件夹,运行:

./configure

生成Makefile文件后!!!!!如果有错误注意错误提示!

随后再:

make
make install

然后在安装expect

安装命令如下:

./configure

生成Makefile文件后,在执行

make
make install

验证expect是否安装成功,只要在控制台输入expect即可,如下图:

写一个.sh脚本来验证下:

first.sh源码如下:

#!/usr/local/bin/expect -f 
spawn su - root
expect "Password:"
send "123456\n"
interact

运行脚本的时候,采用./first.sh和/home/myShell/first.sh这种方式运行

如下图所示:

猜你喜欢

转载自blog.csdn.net/qq78442761/article/details/84062445