无法在期望脚本中执行 bash 脚本

n.d*_*n.d 1 shell scripting bash expect

我有一个像

#!/usr/bin/expect
.....
spawn passwd
expect "password:"
send "password"
....
....
....
~/test.sh
Run Code Online (Sandbox Code Playgroud)

在执行此操作时,我无法运行 bash script test.sh

如何在 Expect 脚本中执行 Linux 命令/bash 脚本?

meu*_*euh 7

您可以使用 tclexec命令,它通常收集输出,因此重定向它:

#!/usr/bin/expect
...
exec ~/test.sh  >@stdout
Run Code Online (Sandbox Code Playgroud)