Linux expect spawn找不到文件

标签 linux bash

我写了一个名为 load_data.exp 的 expect 脚本

#!/usr/bin/expect

spawn "osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore /absolute/path/to/bruges_belgium.osm"
expect "Password:" {send "mysecretpassword"}

更改权限

chmod +x load_data.exp

运行它

./load_data.exp

文件确实存在,它给我错误

spawn osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore /absolute/path/to/bruges_belgium.osm
couldn't execute "osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore /absolute/path/to/bruges_belgium.osm": no such file or directory
while executing
"spawn "osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore /absolute/path/to/bruges_belgium.osm""
(file "./load_data.exp" line 6)

osm2pgsql已经安装好,可以直接在terminal下一句运行

osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore /absolute/path/to/bruges_belgium.osm

我猜spawn有问题

最佳答案

正如错误提示的那样,它试图找到一个不叫 osm2pgsql 的程序,而是一个叫 osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore/absolute/path/to/bruges_belgium.osm 包括所有空格和破折号作为可执行文件名称的一部分。从 spawn 命令中删除引号:

spawn osm2pgsql -s -l -d postgres -W -U postgres -H localhost -P 5432 --hstore /absolute/path/to/bruges_belgium.osm

关于Linux expect spawn找不到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32585342/

相关文章:

linux - x86 指令格式 : "ba 0e 00 00 00" . .. "mov $0xe,%edx"

linux - 组装 - NASM 析因问题

linux - 使用 shell 打开 telnet 并传递命令

ios - 依赖项 `Mixpanel` 未在任何具体目标中使用

bash - 输出特定行的大文本文件

linux - HDMI 无信号 debian

linux - NFS 安装挂起重启

linux - Linux 上 anaconda2 中的 Ipykernel 无法在 Jupyter notebook 中创建新的 virtualenv

linux - 如何找到只对所有者具有特定权限的文件?

bash - 查找并替换当前文本以用颜色包裹