2012-07-30 39 views
0

我想聽一個管道,並寫下這段代碼,但我得到了模糊的重定向錯誤,爲什麼?爲什麼在這裏得到模糊重定向的錯誤?

pipe = "./$1" 

# trap enables to execute a command when a signal is sent to your script 
trap "rm -f $pipe" EXIT 


if [[ ! -p $pipe ]]; then 
    mkfifo $pipe 
fi 


while true 
do 
    if read line <$pipe; then 
     if ["$line" == 'EXIT' -o "$line" == 'exit' ]; then 
      break 
     else 
      echo $line 
     fi 
    fi 
done 

回答

3

我懷疑你的第一線失敗,出現錯誤:

pipe: command not found

由於bash變量賦值不支持變量名和=符號之間的空白。因此,$pipe未定義,read line < $pipe失敗。試試:

pipe="./$1" 
相關問題