我有这样的shell脚本。shell脚本错误
line="[email protected]" # get the complete first line which is the complete script path
name_of_file = ${line%.*}
file_extension = ${line##*.}
if [ $file_extension == "php"]
then
ps aux | grep -v grep | grep -q "$line" || (nohup php -f "$line" > /var/log/iphorex/$name_of_file.log &)
fi
if [ $file_extension == "java"]
then
ps aux | grep -v grep | grep -q "$line" || (nohup java -f "$name_of_file" > /var/log/iphorex/$name_of_file.log &)
fi
这里线变量具有像/var/www/dir/myphp.php
或/var/www/dir/myjava.java
值。
shell脚本的目的是检查这些进程是否已经在运行,如果没有,我尝试运行它们。我得到以下错误。
name_of_file: command not found
file_extension: command not found
[: missing `]'
[: missing `]'
任何想法?
您需要的紧密报价'间空隙的支架问题“'和括号''''如下所示...''php”]' – 2011-03-11 13:57:34
什么shell?脚本是否以'#!'开头? – nmichaels 2011-03-11 13:58:12
然后我得到'name_of_file:找不到命令 FILE_EXTENSION:找不到命令 [:==:一元运算符预期 [:==:一元运算符expected' – ayush 2011-03-11 13:59:05