簡體   English   中英

Linux期望spawn無法找到文件

[英]Linux expect spawn can not find file

我寫了一個名為load_data.exp的期望腳本

#!/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已安裝,可以在終端中直接運行以下語句

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

所以我認為產生是有問題的

正如錯誤所暗示的那樣,它正在嘗試查找一個名為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

嘗試指定osm2pgsql的絕對路徑(由命令“ which osm2pgsql ”獲取)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM