2010-11-23 97 views
0

假設我在〜/編程/ ass1中,並且可執行文件位於〜/ programming/ass1/seattle/seattle_repy/repy.py。創建符號鏈接到程序

我試圖創建像這樣

ln -s seattle/seattle_repy/repy.py repy 

一個符號鏈接可以輸入

python repy restrictions.test example.1.1.repy 

,而不是

python seattle/seattle_repy/repy.py restrictions.test example.1.1.repy 

但它沒有工作(我得到「 python:無法打開文件'/ home/philipp/Desktop/Uni/NTM/UE/Uebungsblatt 3/safe_check.py':[Errno 2]沒有這樣的文件或目錄「)。 所以repy.py找不到safe_check.py。

這可能嗎?

乾杯, 菲利普

+0

WHERE是safe_check.py,你怎麼稱呼它 – Mark 2010-11-23 23:21:24

+0

它也在seattle/seattle_repy /中,它被repy.py所調用。 – 2010-11-23 23:57:37

回答

1

你需要FROB sys.path添加包含模塊的路徑,但它可能更容易讓調用exec python ~/programming/ass1/seattle/seattle_repy/repy.py一個shell腳本。

+0

感謝您的提示。我用〜/編程/ ass1/repy.sh中的bash腳本解決了這個問題。

 #!/bin/bash exec python ~/programming/ass1/seattle/seattle_repy/repy.py $1 $2 
2010-11-24 00:28:38

0

感謝提示Ignacio和Mark。 我在〜/編程/以下bash腳本ASS1解決它

 
#!/bin/bash 
exec python ~/programming/ass1/seattle/seattle_repy/repy.py [email protected] 

終於得到我想要什麼,我就複製到/ usr/bin下創建一個符號鏈接到它:

sudo cp repy.sh /usr/bin/ 
sudo ln -s /usr/bin/repy.sh /usr/bin/repy 

所以現在我只能說repy restrictions.test example.2.1.repy,它會工作。