This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
The community reviewed whether to reopen this question 2 years ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
我遇到了这个问题,发现我没有安装预期的解释器!奇怪的是,如果您在 shell 中运行该命令,它就会起作用。然而,通过 shell 脚本我得到了这个错误:
我通过简单地安装 Expect 解释器来修复它。选择的包名称是:expect libtcl8.6
只需运行:
I had this issue and found I didn't have the expect interpreter installed! Oddly enough, if you ran the command in the shell it worked. However, through a shell script I got this error:
I fixed it by simply installing the Expect interpreter. The package name that was chosen was: expect libtcl8.6
Just run:
是否可能有一个令人困惑的 Windows 换行符(
^M
)剧本?您可以尝试od
来查看expect
和 tofromdos 或编辑器(例如 emacs)将其删除。请参阅手册页以获取更多信息。Is it possible that there's a Windows newline (the
^M
) in there that's confusing the script? You can tryod
to see what newline character(s) is after theexpect
and tofromdos or an editor (e.g. emacs in hexl-mode) to remove it. See the man pages for more info.你的行结尾是错误的。通过
dos2unix
或tr -d '\r'
将其推送。Your line endings are wrong. Shove it through
dos2unix
ortr -d '\r'
.老实说,我真的不知道期望,但是当我在我的系统上运行它时,它“工作”得很好。什么也没发生,但这就是我所期望的。我没有收到任何错误消息。根据手册页,
这是启动脚本的正确方法。 Expect 然后会将您正在执行的脚本作为 cmdfile 读取。
我重现问题的方法是在行尾实际放置一个
^M
而不是普通的换行符(看到 Bert F 的回复 促使我尝试一下)。我确信 vim 的:set list
命令会显示任何奇怪的字符。I don't really know expect, to be honest, but when I run that on my system it "works" fine. Nothing happens, but that's what I'd expect. I don't get any error message. According to the man page,
is the correct way to start your script. Expect then slurps up the script you are executing as the cmdfile.
The way I got it to reproduce the problem was to actually put a
^M
at the end of the line instead of a normal newline (saw Bert F's response and that prompted me to try it). I'm sure vim's:set list
command will show any odd characters.如果您观察到该错误,则存在一个 Windows 换行符,这是因为它是通过邮件或 Winscp 从 Windows 计算机复制而来而添加的。因此,为了避免此错误,请使用 scp linux 将脚本复制到 linux 并执行该脚本。
If you observe the error, there was a windows newline character, that is added because its copied from windows machine via mail or winscp. So to avoid this error copy the script using scp linux to linux and execute the script.