è£äº†å¥½å¹¾æ¬¡ Intel Compiler,æ¯æ¬¡éƒ½è¦é‡å¯«ä¸€å›ž <INSTALLDIR>/bin 目錄裡的指令稿å–代 shell script。
今天å—ä¸äº†äº†ï¼ŒèŠ±é»žæ™‚間寫個 python å°ç¨‹å¼ï¼Œä»¥å¾Œåªè¦æ”¹æ”¹å—串資訊,就å¯ä»¥è‡ªå‹•å¹«å¿™æ”¹å¥½æŒ‡ä»¤ç¨¿è£¡çš„路徑資料。
#!/usr/bin/env python # -*- coding: UTF-8 -*- """ 用來å–代 Intel Compiler 在 Debian 上手動安è£æ™‚, <INSTALLDIR>/bin 目錄內å„指令稿內的安è£ç›®éŒ„ä½ç½®ã€‚ $Id$ """ #################################### # 給 Intel C Compiler 用的å–代資訊 ORIGTAG = "<INSTALLDIR>" ROOT = "/usr/table/share/intel_cc_80" SCRIPTS = [ 'icc', 'icc.cfg', 'iccvars.csh', 'iccvars.sh', 'icpc', 'icpc.cfg', 'uninstall.sh' ] # #################################### def subs(old, new, fn): """ 執行å–ä»£å·¥ä½œçš„å‡½å¼ old: 被å–代å—串 new: æ–°å–代å—串 fn: 工作的目標檔å """ #################################### # import re # 讀å–來æºè³‡æ–™ f = open( fn, 'r' ); orig = f.read(); f.close() # 執行å–代 replaced = re.sub( old, new, orig ) # 把å–代後的整ç†è³‡æ–™å¯«å›žæª”案 f = open( fn, 'w' ) f.write( replaced ) f.close() # #################################### def parameters(): """ 處ç†æŒ‡ä»¤è¡Œå¼•æ•¸ï¼›ç›®å‰æ²’有任何è¦è™•ç†çš„引數。 """ #################################### # from optparse import OptionParser, OptionGroup op = OptionParser( usage = "usage: %prog", version = "%prog, $Revision$" ) (options, args) = op.parse_args() return options, args, op # #################################### def main(): """ 主函å¼ã€‚ """ #################################### # for script in SCRIPTS: subs(ORIGTAG, ROOT, script) # #################################### if __name__ == '__main__': #################################### # main() # ####################################
改好這些路徑資料之後,ä¸è¦å¿˜äº†ä¿®æ£ä¸€ä¸‹ iccvars.sh (å’Œ iccvars.csh) è£¡å° MANPATH 的錯誤處ç†ã€‚
Posted by yungyuc
at 17:21,
0 comment,
0 trackback.
Navigate
- Previous: 好用的機絲 @2005/05/23
- Next: 用 Intel Compiler ç·¨è¯ mpich @2005/05/24
Add a trackback
Please send trackback to: http://blog.seety.org/everydaywork/2005/5/24/334/trackback/.
Add a comment