也许是巴什的差异?在旧服务器上工作得很好,而不是在新服务器上工作。
它从不在get_running_palaces()函数中回显"made“,而是输出
comm: /dev/fd/63:没有这样的文件或目录
comm: /dev/fd/63:没有这样的文件或目录
#!/bin/bash
TYPE=$1
get_palaces(){
for PALACE in $(ls -trI shared /home | sort); do
if [ -d "/home/$PALACE/palace" ]; then
echo $PALACE
fi
done
}
# comm -12 file1 file2 Print only lines present in both file1 and file2.
# comm -3 file1 file2 Print lines in file1 not in file2, and vice vers
get_running_palaces(){
echo "made it";
PSFRONT_A=$(ps ax | grep '[p]sfront -p .* -r /home/.*/palace ' | sed 's| *\([0-9]*\).*/home/\(.*\)/palace.*$|\2|' | uniq | sort)
PSERVER_A=$(ps ax | grep '[p]server.* -f /home/.*/palace/psdata/pserver.conf ' | sed 's| *\([0-9]*\).*/home/\(.*\)/palace.*$|\2|' | sort)
ERRORS=$(comm -3 <(echo "${PSERVER_A[*]}") <(echo "${PSFRONT_A[*]}"))
if [ ! -z "$ERRORS" ]; then
comm -3 <(echo "${PSERVER_A[*]}") <(echo "${ERRORS[*]}")
else
echo "$PSERVER_A"
fi
}
case "$TYPE" in
online)
KNOWN_PALACES=$(get_palaces)
ERROR_LESS=$(get_running_palaces)
ONLINE=$(comm -12 <(echo "${KNOWN_PALACES[*]}") <(echo "${ERROR_LESS[*]}"))
[ ! -z "$ONLINE" ] && echo "$ONLINE"
;;
offline)
KNOWN_PALACES=$(get_palaces | sort)
ERROR_LESS=$(get_running_palaces)
OFFLINE=$(comm -3 <(echo "${KNOWN_PALACES[*]}") <(echo "${ERROR_LESS[*]}"))
[ ! -z "$OFFLINE" ] && echo "$OFFLINE"
;;
*)
get_palaces
;;
esac
exit 0;信息:
新服务器:
不名-a
Linux www.ipalaces.org 2.6.32-274.7.1.el5.028稳定095.1 #1 SMP 10月24日20:49:24 MSD 2011 x86_64 GNU/Linux
lsb_release -rd
-bash: lsb_release:命令not
巴什--版本
GNU,版本4.1.5(1)-release (x86_64-pc)
旧服务器:
不名-a
Linux ipalaces.org 2.6.32-5-686 #1 SMP Mon Jan 16:04:25 UTC 2012 i686 GNU/Linux
lsb_release -rd
描述: Debian /Linux6.0.4(压缩)
发行版: 6.0.4
巴什--版本
GNU,版本4.1.5(1)-release (i 486-pc-linux-gnu)
发布于 2012-03-19 21:55:29
进程替换需要Linux上的/dev/fd/* (我认为它的实现方式取决于Bash是如何构建的)。也许在这个脚本正在运行的时候,您有一个错误的/dev/结构?像这样的事会发生。
我看到过引导时bash脚本试图生成一个需要/tmp的文档失败了,这个文档还没有被挂载(以后还会来自tmpfs,所以根卷或其他任何地方都没有这样的目录)。
进程替换在该系统上是否有效?我的意思是,如果您登录到一个已启动并正在运行的系统,您可以这样做吗?
diff <(echo "a") <(echo "b")如果这样做不起作用,那么要么修复/dev,要么改变Bash的构建方式(让它使用fifo进行进程替换),或者只是更改脚本,使其不依赖于进程替换。
https://stackoverflow.com/questions/9776158
复制相似问题