title: Change value in if statement in Shell script
body: <p>I would like to change the value of the global variable <code>status</code> in my script below, but I don't know what's wrong with this. </p>
  
  <pre><code>status="alive";
  for i in (*code here*)
  do 
    ping -c3 (*host modified by the code*) &gt; /dev/null
    if [ $? -eq 0 ]
    then
      status="alive";
    else
      status="dead";
    fi
  
    if [ "$status" == "alive" ]
    then    
    (*code here*)
    fi
  </code></pre>
  
  <p>this status variable used to check whether host is down or not, if host is not down, then do the ping and otherwise.</p>
  
  <p>So is the last if statement working correctly ??? Please show me where i have mistake. Thanks in advanced!!</p>
  
  <p>PROBLEM SOLVED!!!!</p>