我從github gtfs_SQL_importer複製下面的代碼:如何管多個SQL-和PY-腳本
cat gtfs_tables.sql \
<(python import_gtfs_to_sql.py path/to/gtfs/data/directory) \
gtfs_tables_makeindexes.sql \
vacuumer.sql \
| psql mydbname
我試圖在Windows上運行這一點,並通過窗口相當於取代了調用UNIX命令cat
type
這應該與is-there-replacement-for-cat-on-windows的工作類似。
然而,當我執行的代碼,我得到了一些錯誤:
the syntax for the filename, directory or filesystem is whrong.
於是,我就的管道文件的數量限制爲僅結合調用Python和調用psql
:
type <(C:/python27/python path/to/py-script.py path/to/file-argument) | psql -U myUser -d myDataBase
產生相同的錯誤。
然而,當我獨自一人來執行Python腳本它按預期工作:
C:/python27/python path/to/py-script.py path/to/file-argument
所以我認爲從爲了使用type
管道腳本的結果直接psql
錯誤的結果。
有誰知道正確的語法?
編輯:爲確保問題不相關的文件不被發現,我用我的命令之內的所有參數的絕對路徑,除了type
和psql
-command(這是通過%PATH%
-variable都處理)。
你確定你的語法正確嗎?你在'type'後面有一個重定向操作符。你可以試着做:'輸入gtfs_tables.sql <(C:/ python27/python path/tp/py-script.py path/to/file-argument)| psql -U myUser -d myDataBase'? – puelo
截至http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true'<'-command應該從我的python腳本讀取數據併發送到管道(在我的情況下''psql')。不過,我還在'<'之前添加了第一個sql文件,這會產生相同的消息。 – HimBromBeere
這個部分的輸出是什麼'type <(C:/ python27/python path/to/py-script.py path/to/file-argument)'? – zenlc2000