2014-02-26 63 views
1

我有一個非常簡單的shell腳本。它讀起來像這樣。Shell腳本 - 刪除部分字符串。找不到文件

#!/bin/bash 

echo upload trigram 
bteq < load_temp_trigram 

echo load bigram 
bteq < load_temp_bigram 

echo load word 
bteq < load_temp_word 

echo load phrase 
bteq < load_temp_phrase 

我收到以下錯誤,然後它在腳本執行以下命令

: command not found 
upload trigram 
: No such file or directoryigram 
: command not found 
load bigram 
: No such file or directorygram 
: command not found 
load word 
: No such file or directoryord 
: command not found 
load phrase 

我打電話使用bash script.sh或sh script.sh腳本。

因此,它看起來不能識別回顯命令,即使它似乎工作。它正在切斷字符串/文件 - 這可能是爲什麼它找不到它們。我不知道這裏發生了什麼。任何幫助,將不勝感激。

+7

您的文件CR + LF行結束。使用'dos2unix'或其他實用程序刪除CR。 – devnull

+0

它實際上看起來像它正在識別「回聲」 - 因爲你看到的輸出不是以「:」開始 – Beano

+0

bteq是一個類似於FTP的客戶端......你正在通過重定向與它進行對話單向,並不是一個完美的方式。多個錯誤是你正在餵食bteq的結果。嘗試使用「expect」命令或建立一個對話能力的wrapperscript。不知道你在吃什麼,我們不能說錯誤是什麼 – thom

回答

0

1)添加-x殼這樣

#!/bin/bash -x 

它會降低在一般的問題的量。

如果你想輸出的文本使用2)引用 這樣

echo "upload trigram" 

3)使用絕對路徑的可執行 這樣

/usr/bin/bteq 

路徑到您的BTEQ可執行可能通過執行發現

which bteq 

(如果你是幸運的,有一個裏面裝) 同樣適用於SQL批處理文件

/path/to/td_bins/bteq < /path/to/batch/load_temp_word 

如果用批處理文件的文件夾中,它相對路徑將是./

相關問題