预计会出现“没有这样的文件或目录”错误

问题描述 投票:0回答:1

当我运行expect时,除了expect的额外实例之外,我无法生成任何其他东西。

expect1.1> spawn bluetoothctl
spawn bluetoothctl
couldn't execute "bluetoothctl": no such file or directory
    while executing
"spawn bluetoothctl"
expect1.2> spawn expect
spawn expect
3310
expect1.3> send -- exit
expect1.4> exit

使用 sudo 运行 Expect 不起作用。据我所知,Expect 和 bluetoothctl 具有完全执行权限。使用 bluetoothctl 的完整路径不起作用。

linux expect
1个回答
-2
投票

有可能你的expect交互模式下的环境变量与终端中的环境变量不匹配,导致

spawn
命令找不到
bluetoothctl
命令。

您可以尝试使用

查看您的 PATH 环境变量
send -- echo $PATH\r 

在 EXPECT 交互模式下,然后使用

echo $PATH
命令将其与您在终端中看到的内容进行比较,看看是否有差异。

如果存在差异,您可以尝试使用

bluetoothctl

命令的路径添加到 PATH 环境变量中
send -- export PATH=$PATH:/path/to/bluetoothctl\r 

在expect交互模式下,然后尝试使用

spawn
命令来执行
bluetoothctl
命令。

© www.soinside.com 2019 - 2024. All rights reserved.