On Wed, Feb 26, 2014 at 1:54 PM, Tris Hoar <trishoar at bgfl.org> wrote: > On 26/02/2014 13:45, C. L. Martinez wrote: >> On Wed, Feb 26, 2014 at 1:40 PM, sjt5atra <sjt5atra at gmail.com> wrote: >>> >>> >>> >>> >>>> On Feb 26, 2014, at 8:28 AM, "C. L. Martinez" <carlopmart at gmail.com> wrote: >>>> >>>>> On Wed, Feb 26, 2014 at 12:40 PM, Steven Tardy <sjt5atra at gmail.com> wrote: >>>>> On Wed, Feb 26, 2014 at 6:57 AM, C. L. Martinez <carlopmart at gmail.com>wrote: >>>>> >>>>>> if [ "$cpu_affinity" == "$cpu_affinity_ok" ]; then >>>>> >>>>> are you comparing strings or integers? >>>>> # man test >>>>> STRING1 = STRING2 >>>>> the strings are equal >>>>> INTEGER1 -eq INTEGER2 >>>>> INTEGER1 is equal to INTEGER2 >>>> >>>> Thanks Steven, but it doesn't works also .. >>>> >>>> Using if [ "$cpu_affinity" -eq "$cpu_affinity_ok" ]; then >>>> ./cpu_affinitty: line 7: [: taskset -p -c 27756 | awk '{ print }': >>>> integer expression expected >>> >>> Yes, since you are double quoting you are using strings. Try using a single = sign instead of your original double equal sign. >> >> >> Ok, problem solved. With this compare function: >> >> if [[ "$bro_cpu_affinity" == *"$cpu_affinity_ok"* ]]; then >> >> works ok ... >> >> sjt5atra, using a single =, it doesn't works ... > > The issues are to do with your variable expansion > > [root at srvman ~]# cpu_affinity="taskset -p -c `cat /var/run/crond.pid` | > awk '{print $6}'" > [root at srvman ~]# echo $cpu_affinity > taskset -p -c 2532 | awk '{print }' > > I think your script is still broken, as you are now just looking for any > number matching $cpu_affinity_ok in $cpu_affinity. You should be able to > do an integer comparison for your if statement. > > Tris > Uhmm .. You are right Tris ... The correct option is what John Doe says .. Many thanks to all.