Skip to main content
added 214 characters in body; edited title
Source Link

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function#!/bin/bash
**function start_repair {                                                       
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi
  }**

ERROR: bash: line 5: [: : integer expression expected

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function start_repair {
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi
 }

ERROR: bash: line 5: [: : integer expression expected

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

#!/bin/bash
**function start_repair {                                                       
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi }**

ERROR: bash: line 5: [: : integer expression expected

Markup
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function start_repair { threshold=120 IP=10.194.51.216 echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')" if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then echo "greater than ${threshold}" service cassandra restart PID=$! wait $PID echo done fi }

function start_repair {
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi
}

ERROR: bash: line 5: [: : integer expression expected

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function start_repair { threshold=120 IP=10.194.51.216 echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')" if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then echo "greater than ${threshold}" service cassandra restart PID=$! wait $PID echo done fi }

ERROR: bash: line 5: [: : integer expression expected

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function start_repair {
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi
}

ERROR: bash: line 5: [: : integer expression expected

added 214 characters in body; edited title
Source Link

I created a simple script in bash how to checking *if test integer expression(conditionextracted from the command) > threshold* levelin IF statement

function start_repair {
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi
}

ERROR: bash: line 5: [: : integer expression expectedI created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function start_repair { threshold=120 IP=10.194.51.216 echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')" if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then echo "greater than ${threshold}" service cassandra restart PID=$! wait $PID echo done fi }

ERROR: bash: line 5: [: : integer expression expected

I created a simple script in bash to checking *if (condition) > threshold* level

function start_repair {
        threshold=120
        IP=10.194.51.216
        echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')"
        if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then
          echo "greater than ${threshold}"
          service cassandra restart
          PID=$!
          wait $PID
          echo done
    fi
}

ERROR: bash: line 5: [: : integer expression expected

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

how to test integer expression(extracted from the command) in IF statement

I created a simple script in bash to start system service if system is down for more than threshold value.If part basically check the integer value(extracted from the commnd)with threshold value(integer)

control is not going to if statement. can anyone suggest me the solution for above. how to test integer expression in IF statement.

function start_repair { threshold=120 IP=10.194.51.216 echo "$((systemctl status cassandra | awk'/(Active:failed)/{print$10}')| awk '{print ($0+0)}')" if [[ "$((systemctl status cassandra | awk '/(Active: failed)/{print $10}') | awk '{print ($0+0)}')" -gt "${threshold}" ]]; then echo "greater than ${threshold}" service cassandra restart PID=$! wait $PID echo done fi }

ERROR: bash: line 5: [: : integer expression expected

Markup
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k
Loading
Source Link
Loading