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 6732117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:36:39+00:00 2026-05-26T10:36:39+00:00

Basically this is my code: bay=$(prog -some flags) while [ $bay = Another instance

  • 0

Basically this is my code:

bay=$(prog -some flags)
while [ $bay = "Another instance of this program is running, please exit it first" ]
do
echo "Awaiting Access to program"
do
.....

I have program which will only allow one instance to be run at one time due to the way it interacts with my hardware, when another instance is running it kicks out the following message “Another instance of this program is running, please exit it first”.

I need to beable to run multiple scripts which will utilise this same program so I’ve decided to use the above code. My problem is that when I run my two scripts one will gain access to the program and run as desired but the other will notice the error and then get stuck in an infinate loop echoing “Awaiting Access to program”.

Have missed some thing? Is the Statement executing the CLI command or just reffering back to its origanal execution? Or is my problem else where?

  • 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-05-26T10:36:40+00:00Added an answer on May 26, 2026 at 10:36 am

    You are not updating your bay variable inside of the loop somewhere. It gets set once and stays the same. You need to recalculate it every time.

    Either set bay within the loop, or in the condition of the while.

    while [ `prog -some flags` = "Another instance of this program is running, please exit it first" ]
    

    Edit:

    From your comment, you want to be able to reference this output later. You can go back to what you had, but inside of your blocking loop, put your bay=$(prog -some flags) command inside of the loop. It will stick around for you to use later.

    bay=$(prog -some flags)
    while [ $bay = "Another instance of this program is running, please exit it first" ]
    do
    echo "Awaiting Access to program"
    bay=$(prog -some flags)
    done
    .....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So basically this code was working fine before. I had some computer issues and
I recently came across this in some code - basically someone trying to create
So I was writing some code today that basically looks like this: string returnString
So I have found this code here This basically lets me pull some data
Basically this code below returns the right information, but I need to add the
This code basically translates characters based on position in one string to the character
I am using this code to alter the title of an image. Basically it
I basically want to do this in code: PersonList myPersonList; //populate myPersonList here, not
Basically i am having problems with my code - this is homework so would
I'm trying to modify the code from this script . Basically I'm trying to

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.