2012-07-30 38 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" 
相关问题