2011-03-30 103 views
1

我有大約20個腳本,每個產生一個輸出文件作爲輸出,作爲輸入反饋到下一個文件。我現在要爲用戶提供一個選項,以便從腳本的任何位置重新啓動批處理腳本。寫入批處理腳本的最佳方式是什麼?

我的朋友建議使用make或ant來爲每個python腳本定義目標。我想知道你的(高級黑客)建議。

謝謝

回答

2

製作是這樣工作的:

Target: dependencies 
    commands 

根據您的腳本,你可以嘗試這種類型的Makefile:

Step20: output19 
    script20 #reads output19 and produces final output 

Step19: output18 
    script19 # reads output18 and produces output19 

.. etc .. 

Step2: output1 
    script2 # reads output1 and produces output2 

Step1: 
    script1 # produces output1 

這樣一來,每個腳本不會一直運行到上一步的輸出已經產生。運行使步驟20將沿着整個鏈向下,如果沒有任何輸出存在,​​則從script1開始。或者,如果output15存在,它將開始運行script16。

相關問題