推 dryman:!python foo.py & 這樣? 01/09 20:02
似乎不行耶...附上程式碼 & 錯誤訊息
// foo.py
input = raw_input('input something:')
print 'you input:' + input
:!python % 沒問題, 但 :!python % &會有錯誤(看不太懂...):
// output
input something:Traceback (most recent call last):
File "foo.py", line 1, in <module>
input = raw_input('input something:')
EOFError: EOF when reading a line
Press ENTER or type command to continue
// 截圖
http://www.dumpt.com/img/viewer.php?file=qmtq01aq80gl2w1pfho1.jpg

→ yoco315:你的外部指令正打算從 stdin 讀東西耶.. 01/09 21:23
→ yoco315:你讓他在背景跑 請問你要他讀什麼 @@? 01/09 21:23
→ Holocaust123:對吼...我在幹嘛~"~ 01/09 21:27
→ kornelius:改成使用 system 然後 pipe 到 log file 01/10 10:10
→ kornelius:再用 tail -f logfile 就很好用了。 01/10 10:11
→ kornelius:寫個 script 包起來,自動餵 stdin 01/10 10:11
謝謝版主大人~
我試了一個下午
想到一個不需寫script餵stdin的方法:
:!screen bash -c "python \"%\" ; read -p \"press any key to continue...\""
※ 編輯: Holocaust123 來自: 140.112.30.32 (01/10 18:25)
推 dryman:也可以預先把要stdin的東西弄成一個檔,然後pipe進去 01/10 19:23
推 letoh:弄個 fifo 應該也很方便? mkfifo 01/16 17:03