shell中執行jar程序,並且手動配置執行此jar程序的jdk環境,執行腳本爲:
#!/bin/sh export JAVA_HOME=/home/hadoop/szw/jdk1.8.0_25 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH echo `date` java -jar stanford.jar edu.stanford.nlp.wordseg.ChineseDictionary -inputDicts in.txt -output dict.ser.szw.gz echo `date` java -jar stanford_model.jar edu.stanford.nlp.ie.crf.CRFClassifier -prop ctb.prop -serDictionary dict.ser.szw.gz -sighanCorporaDict data -trainFile in.txt -serializeTo newmodel.ser.szw.gz > newmodel.log 2> newmodel.err echo `date` //打印時間,其中`爲tab鍵上面的按鍵
用此腳本執行時卻總是報錯,': not a valid identifierport: `,試了很多種方法總是找不到錯誤原因,最後發現是腳本文件格式的問題,需要把此腳本轉化爲UNIX格式,腳本我是用notepad++編輯的,保存是默認爲Windows格式的,將此轉化爲UNIX後執行正常。