以下腳本一臺服務器上工作正常,工作正常,在一臺服務器上,但另一方面,它提供了一個錯誤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