I have a shell script like this.
line="$@" # 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
here line variable has values like /var/www/dir/myphp.php or /var/www/dir/myjava.java.
The purpose of shell script is to check if these processes are already running and if not i try to run them.I get the following errors.
name_of_file: command not found
file_extension: command not found
[: missing `]'
[: missing `]'
Any ideas?
"and the close bracket]like the following..."php" ]#!?name_of_file: command not found file_extension: command not found [: ==: unary operator expected [: ==: unary operator expectedpsand series of greps with simplypgrep. For example:pgrep "$line" > /dev/null || your_cmd