2017-08-18 26 views
0

我有一个相当长的bash脚本。我想用漂亮的运行bash脚本,出现错误的结果很好

不错的运行./test1.scr

如果我不漂亮运行脚本,它的伟大工程。但是,当我运行它很好。在我的脚本中运行的命令失败。

commandout=() 
while IFS= read -r line # Read a line 
do 
    commandout+=("$line") # Append line to the array 
done < <(tmsh show ltm pool $pool detail | grep -A5 "Ltm::Pool") 
commandout+=(" ") 

我碰到下面的错误,如果我跑漂亮

./test1.scr: line 269: syntax error near unexpected token `<' 
./test1.scr: line 269: `      done < <(tmsh show ltm pool $pool detail | grep -A5 "Ltm::Pool")' 

剧本,如果我不运行脚本漂亮一切工作正常。

我想好的整个脚本,所以我可以减少冲击到其他进程,而这种运行

+3

'.scr'文件是否以'#!/ bin/bash'开头?否则,''nice'可能会使用'sh'来启动它。在许多版本的Linux上,'sh'实际上是'dash',它并不知道bash'知道的所有技巧。 – axiac

+0

您可能想使用'readarray -t commandout <<(tush show ltm pool“$ pool”detail | grep -A5“Ltm :: Pool”)''代替。 – chepner

回答

0

你没有张贴作为答案,所以我不能将其标记为答案。但OMG我太吓人了。

脚本以#/bin/bash开头,而不是#!/bin/bash修复它。