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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:44:33+00:00 2026-05-20T03:44:33+00:00

I have written a large script to run a series of tests. Each test

  • 0

I have written a large script to run a series of tests. Each test is a function on its own and I call these functions serially to get the job done.

I now want to make provisions to resume script run from the last function where it was aborted (e.g. in case system hangs). The logic I am using now is to write progress status into a file and then check the file content to determine where to start the script and resume from there.

However, I can’t continue using this logic because I want to introduce a menu into the script where I want to be able to choose from:

1) Run all tests from beginning to end
2) Run individual tests (brings up another menu with individual test options)
3) Resume from last abort

I have the written the code for the menu but still haven’t figured out how to fit my existing logic with the case construct used in my menu system. I am unhappy with the current resume from last abort logic I am using presently, which is:

fn1()
{
  #do a bunch of things
  echo 1 > progress.log
  fn2
}

fn2()
{
STATUS=`cat progress.log`
case "$STATUS" in 
1)
  #do a bunch of things
  echo 2 > progress.log
  fn3
;;
*)
 fn3
;;
esac
}

..
..
# and more functions in the same style as fn2
..

# main call

if [ -f progress.log ]
 fn2
else
 fn1
fi

Any ideas for a cleaner way to do this resume logic while integrating it with the ability to run tests individually when required? Thanks.

  • 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-20T03:44:33+00:00Added an answer on May 20, 2026 at 3:44 am

    How about something like this. Drop the logic in fn1..N that link them together, but still write the progress.log file in there, and then do this:

    runtest()
    {
        # run test X where X is 1..N
        case "$1" in
        1) fn1 ;;
        2) fn2 ;;
        3) fn3 ;;
        *) echo "Invalid test number $1" ;;
        esac
    }
    
    runtests()
    {
        START="$1"; shift
        [ -z "$START"] && START=1 # default to test 1
        for i in $(seq "$START" 50); do # replace 50 with max test number
            runtest $i
        done
    }
    
    # from your menu, run from start:
    runtests 1
    # from menu, run from progress
    runtests $(< progress.log)
    # from menu, run test TESTNUM
    runtest $TESTNUM
    # or by name (this is dangerous if you don't trust the user):
    eval "$TESTNAME"
    

    EDIT: with this version, you can just replace fn1, fn2, etc with the test names, so that you still get a runtest N interface that you can use to tie it all together.

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

Sidebar

Related Questions

I currently have a script written that begins downloading an large (1.3GB) XML file
I have written a simple C++ shell program to parse large XML files and
I have a large module written in JS which uses Canvas to draw and
I have a large simulation written in C++. The main working unit for the
We have a large project mainly written in C# (services, multithreading etc.). However, the
We have a rather large and complex application written in Java which is running
I have a Linux app (written in C) that allocates large amount of memory
I have a rather large project whose Installer is written using NSIS. My problem
I have written a bash script which installs a number of packages, however for
I have written a java program that tests the speed of a couple of

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.