2014-08-29 43 views
0
運行shell命令

我想在我的Rake文件試圖在Rake文件

exclusions = args.version >= "7" ? " -t [email protected]" : "" 
current_date = DateTime.now.to_s 
t.cucumber_opts = "-r Frank/features " + args.selection + (args.idiom == "ipad" ? " -t [email protected]" : " -t [email protected]") + exclusions + " --out ci_artifacts/frank_results"+current_date+".txt --format pretty --format html --out ci_artifacts/frank_results.html --format junit --out ci_artifacts" 
sh 'tail -n 3 ci_artifacts/frank_results" + current_date + ".txt >> frank_runtimes.txt' 

運行以下shell命令,當我在sh運行shell命令,我試圖訪問沒有按」文件t已經存在了,但是如果我嘗試運行cucumber_opts中的命令,它不能識別tail命令並且需要一個目錄。

基本上我想要做的就是保存Frank的所有輸出,然後獲取實際的輸出時間並將它們保存在不同的文件夾中。

回答

0

$PATH$PWD可能不是您在從其他程序運行shell命令時所期望的。解決這個問題的最好方法是爲每個引用的文件指定完整路徑,可以按字面(如下例)或使用變量來引用像腳本所在的目錄或用戶的主目錄。

sh '/usr/bin/tail -n 3 /path/to/ci_artifacts/frank_results" + current_date + ".txt >> /path/to/frank_runtimes.txt'