以下脚本一台服务器上工作正常,工作正常,在一台服务器上,但另一方面,它提供了一个错误shell脚本,但没有其他
#!/bin/bash
processLine(){
line="[email protected]" # get the complete first line which is the complete script path
name_of_file=$(basename "$line" ".php") # seperate from the path the name of file excluding extension
ps aux | grep -v grep | grep -q "$line" || (nohup php -f "$line" > /var/log/iphorex/$name_of_file.log &)
}
FILE=""
if [ "$1" == "" ]; then
FILE="/var/www/iphorex/live/infi_script.txt"
else
FILE="$1"
# make sure file exist and readable
if [ ! -f $FILE ]; then
echo "$FILE : does not exists. Script will terminate now."
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE: can not be read. Script will terminate now."
exit 2
fi
fi
# read $FILE using the file descriptors
# $ifs is a shell variable. Varies from version to version. known as internal file seperator.
# Set loop separator to end of line
BACKUPIFS=$IFS
#use a temp. variable such that $ifs can be restored later.
IFS=$(echo -en "\n")
exec 3<&0
exec 0<"$FILE"
while read -r line
do
# use $line variable to process line in processLine() function
processLine $line
done
exec 0<&3
# restore $IFS which was used to determine what the field separators are
IFS=$BAKCUPIFS
exit 0
我只是想读取包含的各种路径的文件脚本,然后检查这些脚本是否已经运行,如果没有运行它们。文件/var/www/iphorex/live/infi_script.txt
肯定存在。我的亚马逊服务器上出现以下错误 -
[: 24: unexpected operator
infinity.sh: 32: cannot open : No such file
感谢您的帮助提前。
使用bash命令运行它的工作。你是对的我的其他shell不喜欢==测试。 – ayush 2011-02-07 14:07:23