Artificial intelligent assistant

Getting expr: syntax error on index Using this OF=$(ps fax | grep 'php-fpm: master process' | awk '{print $1}') IDX=`expr index $OF ' '` I get an error. The results of the $OF variable are: 27797 27495 What is the error here? I think it has to do with how the variable is being passed into the expression. Also, have tried putting ' quotes around the $OF variable to no avail. That just returns 0 as not found.

You should use `pgrep` to grep the **Process ID** of a process. This is the safest way there is. Some systems(legacy systems) don't have `pgrep` so you'd be forced to use something as `ps`. In case you use `ps` You should consider the following. Your line uses `grep` and `awk` which is not necessary as you could handle all that using awk.


of=$(ps fax | awk '/[p]hp-fpm: master process/{print $1}')


As a side note. Don't use upper case for normal variable names. By convension, Environment variables are CAPITALIZED.

At this stage your variable `$of` will hold the process id of the `php-fpm`. Since your question is not clear, I'm not sure what `expr` is doing there.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ad81229e51a4f6b07a5bbf0ccee0e1c9