Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:29:19+00:00 2026-06-16T00:29:19+00:00

My OS is CentOS 6.3. I have a bash script that gets mysql slave

  • 0

My OS is CentOS 6.3.
I have a bash script that gets mysql slave status and gives user menu with some actions. When an action is made it refreshes itself. Here is a simplified example:

#!/bin/sh
server_status_detect () { 
  rm -f /root/slave.status
  mysql -u${MYSQL_USER} -p${MYSQL_PASS} -e 'show slave status \G' 2>&1 1>/root/slave.status
  #some parsing of the file to see if threads are running and so on, done like this
  Slave_IO_Running=$(grep '\sSlave_IO_Running:' /root/slave.status | awk '{ print $2 }');
}
themenu () {
  clear
  server_status_detect
  echo -e "Slave running? "$Slave_IO_Running;
  echo "Available actions:"
  #print actions
}

while true
 do
   themenu
   read answer
  case $answer in
        e)  menu_network_pick;;
        d)  menu_mount_pick;;
        m)  menu_master_pick;;
        p)  menu_repair_replication_pick;;
        t)  menu_restart_replication_pick;;
        r)  menu_reboot_pick;;
        s)  menu_shutdown_pick;;
        *) continue;;
   esac
done

Everything works as expected, status file is recreated each iteration, it contains actual data. BUT, script shows fist parsed data! Seems like it doesnt parse file every iteration, it only does it first time and after that just shows results it remembered. How could that happen?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:29:20+00:00Added an answer on June 16, 2026 at 12:29 am

    Shame on me! I made a stupid mistake!

    Just before grepping I had an if which becomes false for second and concurrent iterations thus greps were even not executing and thus variables remain unchanged. Issue closed, bash is not crazy, it’s all about human 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script that I use on a supercomputer (CentOS). This computer
On my Centos 6.2 I have this bash script: [le_me]$ cat get.nb #! /bin/bash
I have an init.d script that looks like: #!/bin/bash # chkconfig 345 85 60
Context: I have a bash script that contains a subshell and a trap for
I have a website in PHP, Lighttpd. It uses also MySQL on Centos 5.
I need some help with priviligies in centos I have a file in home/admin/public_html/generate.php
I have a clean install of a CentOs with php 5.2.13. In php.ini that
My same BASH script is working in Fedora/CentOS. But I am testing one Android
I have some guys here who have code that needs to be compiled with
I have a Linux CENTOS server that is very low on its resources (consider

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.