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

  • Home
  • SEARCH
  • 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 9035027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:39:12+00:00 2026-06-16T08:39:12+00:00

I have been facing a very peculiar issue with shell scripts. Here is the

  • 0

I have been facing a very peculiar issue with shell scripts.

Here is the scenario

Script1 (spawns in background)–> Script2

Script2 has the following code

function check_log()
{
    logfile=$1
    tail -5f ${logfile} | while read line
    do
      echo $line
      if echo $line|grep "${triggerword}";then
        echo "Logout completion detected"
        start_leaks_detection
        triggerwordfound=true
        echo "Leaks detection complete"
      fi
      if $triggerwordfound;then
        echo "Trigger word found and processing complete.Exiting"
        break
      fi

    done
        echo "Outside loop"
        exit 0

}

check_log "/tmp/somefile.log" "Logout detected"

Now the break in while loop does not help here. I can see “Logout completion detected” as well as “Leaks detection complete” being echoed on the stdout, but not the string “outside loop”

I am assuming this has to do something with tail -f creating a subshell. What I want to do is, exit that subshell as well as exit Script2 to get control back to Script1.

Can someone please shed some light on how to do this?

  • 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-16T08:39:13+00:00Added an answer on June 16, 2026 at 8:39 am

    Try this, although it’s not quite the same (it doesn’t skip the beginning of the log file at startup):

    triggerwordfound=
    while [ -z "$triggerwordfound" ]; do
        while read line; do
            echo $line
            if echo $line|grep "${triggerword}";then
                echo "Logout completion detected"
                start_leaks_detection
                triggerwordfound=true
                echo "Leaks detection complete"
            fi
        done
    done < "$logfile"
    echo "Outside loop"
    

    The double loop effectively does the same thing as tail -f.

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

Sidebar

Related Questions

I have been facing issue with sphinx result set for string attribute. Below is
I've been facing in the last days a very weird and specific issue under
My very first post here! I have been using this site for many years
I'm facing a very strange behavior of UIBarButtonItem . I have been able to
We have been facing an issue with displaying the list of States in a
I have been facing an issue. I implemented push notification in iOS with custom
I have a very complex issue that Me and my coworker have been discussing
We have been facing Out of Memory errors in our App server for sometime.
Hell All, So I have been facing this behavior for quite some time and
I have been asked to work of a very large web application and deploy

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.