2016-05-09 133 views
-1

我有一個bash腳本,裏面有各種python腳本,我猜應該一個接一個地運行。Python腳本在執行前等待另一個腳本

第一個腳本是從站點下載torrent的腳本,第二個腳本是unrar內容的腳本。

問題是,unrar腳本不會等待torrent完成,所以我只得到它的一部分。

是否有某種方式告訴腳本只有在torrent完成時才啓動?

+2

您將需要提供一些代碼或這是一個猜謎遊戲。 – andlrc

回答

0

如果您正在使用使用os.system執行腳本,那麼一個簡單的解決方案可能是 進口OS

if (os.system("python script whatever") == 0): 
    print("Your script was terminated and here you can add the rest) 
else: 
    print("Execution errors and do something else") 

否則,您可以檢查其他答案喜歡子模塊:-)

請讓我知道這是否有幫助。

1

這是bash腳本。 dwtor.py下載的torrent,unrar.py顯然unrar的內容..等等..

#!/bin/bash 

python dwtor.py      

python unrar.py  

cd P2             

python /home/disk/user/pyrocore/ 
+0

爲什麼不按照上面的建議在python腳本中推動所有內容?否則,這是一個bash問題,你可以在你的腳本中使用括號,如果情況如下:if(echo「your_first_script」);然後echo「WAS OK ... second_script」; else echo「error message」; fi 再次更好方式和控制你可以直接在python中找到。祝你今天愉快。 –

相關問題